//@cond
guard_data()
- : pPost( null_ptr<guarded_ptr>())
+ : pPost( nullptr )
#if 0
- , pHandOff( null_ptr<handoff_ptr>() )
+ , pHandOff( nullptr )
#endif
- , pGlobalNext( null_ptr<guard_data *>() )
- , pNextFree( null_ptr<guard_data *>() )
- , pThreadNext( null_ptr<guard_data *>() )
+ , pGlobalNext( nullptr )
+ , pNextFree( nullptr )
+ , pThreadNext( nullptr )
{}
void init()
{
- pPost.store( null_ptr<guarded_ptr>(), CDS_ATOMIC::memory_order_relaxed );
+ pPost.store( nullptr, CDS_ATOMIC::memory_order_relaxed );
}
//@endcond
/// Checks if the guard is free, that is, it does not contain any pointer guarded
bool isFree() const
{
- return pPost.load( CDS_ATOMIC::memory_order_acquire ) == null_ptr<guarded_ptr>();
+ return pPost.load( CDS_ATOMIC::memory_order_acquire ) == nullptr;
}
};
public:
// Default ctor
guard_allocator()
- : m_GuardList( null_ptr<guard_data *>() )
- , m_FreeGuardList( null_ptr<guard_data *>() )
+ : m_GuardList( nullptr )
+ , m_FreeGuardList( nullptr )
{}
// Destructor
~guard_allocator()
{
guard_data * pNext;
- for ( guard_data * pData = m_GuardList.load( CDS_ATOMIC::memory_order_relaxed ); pData != null_ptr<guard_data *>(); pData = pNext ) {
+ for ( guard_data * pData = m_GuardList.load( CDS_ATOMIC::memory_order_relaxed ); pData != nullptr; pData = pNext ) {
pNext = pData->pGlobalNext.load( CDS_ATOMIC::memory_order_relaxed );
m_GuardAllocator.Delete( pData );
}
*/
void free( guard_data * pGuard )
{
- pGuard->pPost.store( null_ptr<void *>(), CDS_ATOMIC::memory_order_relaxed );
+ pGuard->pPost.store( nullptr, CDS_ATOMIC::memory_order_relaxed );
cds::lock::scoped_lock<SpinLock> al( m_freeListLock );
pGuard->pNextFree.store( m_FreeGuardList.load(CDS_ATOMIC::memory_order_relaxed), CDS_ATOMIC::memory_order_relaxed );
pLast = p;
}
- pLast->pNextFree.store( pLast->pThreadNext = null_ptr<guard_data *>(), CDS_ATOMIC::memory_order_relaxed );
+ pLast->pNextFree.store( pLast->pThreadNext = nullptr, CDS_ATOMIC::memory_order_relaxed );
return pHead;
}
*/
void freeList( guard_data * pList )
{
- assert( pList != null_ptr<guard_data *>() );
+ assert( pList != nullptr );
guard_data * pLast = pList;
while ( pLast->pThreadNext ) {
- pLast->pPost.store( null_ptr<void *>(), CDS_ATOMIC::memory_order_relaxed );
+ pLast->pPost.store( nullptr, CDS_ATOMIC::memory_order_relaxed );
guard_data * p;
pLast->pNextFree.store( p = pLast->pThreadNext, CDS_ATOMIC::memory_order_relaxed );
pLast = p;
public:
//@cond
retired_ptr_buffer()
- : m_pHead( null_ptr<retired_ptr_node *>() )
+ : m_pHead( nullptr )
, m_nItemCount(0)
{}
~retired_ptr_buffer()
{
- assert( m_pHead.load(CDS_ATOMIC::memory_order_relaxed) == null_ptr<retired_ptr_node *>());
+ assert( m_pHead.load( CDS_ATOMIC::memory_order_relaxed ) == nullptr );
}
//@endcond
privatize_result privatize()
{
privatize_result res;
- res.first = m_pHead.exchange( null_ptr<retired_ptr_node *>(), CDS_ATOMIC::memory_order_acq_rel );
+ res.first = m_pHead.exchange( nullptr, CDS_ATOMIC::memory_order_acq_rel );
// Item counter is needed only as a threshold for liberate function
// So, we may clear the item counter without synchronization with m_pHead
item * pLastItem = pNew->items + m_nItemPerBlock - 1;
for ( item * pItem = pNew->items; pItem != pLastItem; ++pItem ) {
pItem->m_pNextFree = pItem + 1;
- CDS_STRICT_DO( pItem->m_pNext = null_ptr<item *>() );
+ CDS_STRICT_DO( pItem->m_pNext = nullptr );
}
// link new block to block list
public:
//@cond
retired_ptr_pool()
- : m_pBlockListHead(null_ptr<block *>())
+ : m_pBlockListHead( nullptr )
, m_nCurEpoch(0)
- , m_pGlobalFreeHead( null_ptr<item *>())
+ , m_pGlobalFreeHead( nullptr )
{
for (unsigned int i = 0; i < sizeof(m_pEpochFree)/sizeof(m_pEpochFree[0]); ++i )
- m_pEpochFree[i].store( null_ptr<item *>(), CDS_ATOMIC::memory_order_relaxed );
+ m_pEpochFree[i].store( nullptr, CDS_ATOMIC::memory_order_relaxed );
allocNewBlock();
}
} while ( !m_pGlobalFreeHead.compare_exchange_weak( pItem, pItem->m_pNextFree, CDS_ATOMIC::memory_order_release, CDS_ATOMIC::memory_order_relaxed ));
success:
- CDS_STRICT_DO( pItem->m_pNextFree = null_ptr<item *>() );
+ CDS_STRICT_DO( pItem->m_pNextFree = nullptr );
return *pItem;
}
*/
void free_range( retired_ptr_node * pHead, retired_ptr_node * pTail )
{
- assert( pHead != null_ptr<retired_ptr_node *>() );
- assert( pTail != null_ptr<retired_ptr_node *>() );
+ assert( pHead != nullptr );
+ assert( pTail != nullptr );
unsigned int nEpoch;
item * pCurHead;
public:
/// Initialize empty guard.
guard()
- : m_pGuard(null_ptr<details::guard_data *>())
+ : m_pGuard( nullptr )
{}
/// Object destructor, does nothing
/// Guards pointer \p p
void set( void * p )
{
- assert( m_pGuard != null_ptr<details::guard_data *>() );
+ assert( m_pGuard != nullptr );
m_pGuard->pPost.store( p, CDS_ATOMIC::memory_order_release );
//CDS_COMPILER_RW_BARRIER;
}
/// Clears the guard
void clear()
{
- assert( m_pGuard != null_ptr<details::guard_data *>() );
- m_pGuard->pPost.store( null_ptr<void *>(), CDS_ATOMIC::memory_order_relaxed );
+ assert( m_pGuard != nullptr );
+ m_pGuard->pPost.store( nullptr, CDS_ATOMIC::memory_order_relaxed );
CDS_STRICT_DO( CDS_COMPILER_RW_BARRIER );
}
/// Set guard data
void set_guard( details::guard_data * pGuard )
{
- assert( m_pGuard == null_ptr<details::guard_data *>() );
+ assert( m_pGuard == nullptr );
m_pGuard = pGuard;
}
*/
static GarbageCollector& instance()
{
- if ( m_pManager == null_ptr<GarbageCollector *>() )
+ if ( m_pManager == nullptr )
throw PTBManagerEmpty();
return *m_pManager;
}
/// Checks if global GC object is constructed and may be used
static bool isUsed() CDS_NOEXCEPT
{
- return m_pManager != null_ptr<GarbageCollector *>();
+ return m_pManager != nullptr;
}
public:
public:
ThreadGC()
: m_gc( GarbageCollector::instance() )
- , m_pList( null_ptr<details::guard_data *>() )
- , m_pFree( null_ptr<details::guard_data *>() )
+ , m_pList( nullptr )
+ , m_pFree( nullptr )
{}
/// Dtor calls fini()
if ( m_pList ) {
m_gc.freeGuardList( m_pList );
m_pList =
- m_pFree = null_ptr<details::guard_data *>();
+ m_pFree = nullptr;
}
}
/// Initializes guard \p g
void allocGuard( Guard& g )
{
- assert( m_pList != null_ptr<details::guard_data *>() );
+ assert( m_pList != nullptr );
if ( m_pFree ) {
g.m_pGuard = m_pFree;
m_pFree = m_pFree->pNextFree.load(CDS_ATOMIC::memory_order_relaxed);
/// Frees guard \p g
void freeGuard( Guard& g )
{
- assert( m_pList != null_ptr<details::guard_data *>() );
- g.m_pGuard->pPost.store( null_ptr<void *>(), CDS_ATOMIC::memory_order_relaxed );
+ assert( m_pList != nullptr );
+ g.m_pGuard->pPost.store( nullptr, CDS_ATOMIC::memory_order_relaxed );
g.m_pGuard->pNextFree.store( m_pFree, CDS_ATOMIC::memory_order_relaxed );
m_pFree = g.m_pGuard;
}
template <size_t Count>
void allocGuard( GuardArray<Count>& arr )
{
- assert( m_pList != null_ptr<details::guard_data *>() );
+ assert( m_pList != nullptr );
size_t nCount = 0;
while ( m_pFree && nCount < Count ) {
template <size_t Count>
void freeGuard( GuardArray<Count>& arr )
{
- assert( m_pList != null_ptr<details::guard_data *>() );
+ assert( m_pList != nullptr );
details::guard_data * pGuard;
for ( size_t i = 0; i < Count - 1; ++i ) {
pGuard = arr[i].get_guard();
- pGuard->pPost.store( null_ptr<void *>(), CDS_ATOMIC::memory_order_relaxed );
+ pGuard->pPost.store( nullptr, CDS_ATOMIC::memory_order_relaxed );
pGuard->pNextFree.store( arr[i+1].get_guard(), CDS_ATOMIC::memory_order_relaxed );
}
pGuard = arr[Count-1].get_guard();
- pGuard->pPost.store( null_ptr<void *>(), CDS_ATOMIC::memory_order_relaxed );
+ pGuard->pPost.store( nullptr, CDS_ATOMIC::memory_order_relaxed );
pGuard->pNextFree.store( m_pFree, CDS_ATOMIC::memory_order_relaxed );
m_pFree = arr[0].get_guard();
}