atomics::atomic<unsigned int> nState; ///< Record state: inactive, active, removed
atomics::atomic<unsigned int> nAge; ///< Age of the record
atomics::atomic<publication_record *> pNext; ///< Next record in publication list
- void * pOwner; ///< [internal data] Pointer to \ref kernel object that manages the publication list
/// Initializes publication record
publication_record()
, nState( inactive )
, nAge( 0 )
, pNext( nullptr )
- , pOwner( nullptr )
{}
/// Returns the value of \p nRequest field
{
// mark all publication record as detached
for ( publication_record* p = m_pHead; p; ) {
- p->pOwner = nullptr;
-
publication_record * pRec = p;
p = p->pNext.load( memory_model::memory_order_relaxed );
free_publication_record( static_cast<publication_record_type *>( pRec ));
if ( !pRec ) {
// Allocate new publication record
pRec = cxx11_allocator().New();
- pRec->pOwner = reinterpret_cast<void *>( this );
m_pThreadRec.reset( pRec );
m_Stat.onCreatePubRecord();
}
{
// Thread done
// pRec that is TLS data should be excluded from publication list
- if ( pRec ) {
- if ( pRec->pOwner ) {
- // kernel is alive
- pRec->nState.store( removed, memory_model::memory_order_release );
- }
- else {
- // kernel already deleted
- free_publication_record( pRec );
- }
- }
+ pRec->nState.store( removed, memory_model::memory_order_release );
}
static void free_publication_record( publication_record_type* pRec )
assert( m_pThreadRec.get() == nullptr );
publication_record_type* pRec = cxx11_allocator().New();
m_pHead = pRec;
- pRec->pOwner = this;
m_pThreadRec.reset( pRec );
m_Stat.onCreatePubRecord();
}