/** * Decrease the reference count of a piece of memory \a m, * which becomes available for allocation. */ bool deallocate( pointer m ) { Item* it = reinterpret_cast<Item*>(m); if ( oro_atomic_read(&it->rc) == 0 ) return false; if( oro_atomic_dec_and_test( &(it->rc) ) ) if ( mpool.enqueue( static_cast<void*>(m) ) == false ) assert(false && "Deallocating more elements than allocated !"); return true; }
/** * Deallocate and unlock() a piece of memory. * Returns false if already released. */ bool deallocate( pointer m ) { Item* item = reinterpret_cast<Item*>(m); if ( oro_atomic_read(&item->rc) == 0 ) return false; if( oro_atomic_dec_and_test( &(item->rc) ) ) { for ( typename PoolType::iterator it = mpool.begin(); it != mpool.end(); ++it ) { if ( it->first->enqueue( static_cast<void*>(m) ) ) { return true; } } assert(false && "Deallocating more elements than allocated !"); } return true; }
void ChannelElementBase::deref() { if ( oro_atomic_dec_and_test(&refcount) ) delete this; }
bool dec_and_test() { return oro_atomic_dec_and_test( &_val ) != 0; }