bool add_ref_lock() // true on success { NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); bool r = use_count_ == 0? false: ( ++use_count_, true ); NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); return r; }
long use_count() const // nothrow { NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long r = use_count_; NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); return r; }
sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) { // HPUX 10.20 / DCE has a nonstandard pthread_mutex_init #if defined(__hpux) && defined(_DECTHREADS_) NDNBOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 ); #else NDNBOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 ); #endif }
void weak_release() // nothrow { NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long new_weak_count = --weak_count_; NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_weak_count == 0 ) { destroy(); } }
void release() // nothrow { NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); long new_use_count = --use_count_; NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); if( new_use_count == 0 ) { dispose(); weak_release(); } }
void release_waiters(state_data old_state) { if(old_state.exclusive_waiting) { NDNBOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[exclusive_sem],1,0)!=0); } if(old_state.shared_waiting || old_state.exclusive_waiting) { NDNBOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); } }
void add_ref_copy() { NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); ++use_count_; NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); }
virtual ~sp_counted_base() // nothrow { NDNBOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 ); }
void weak_add_ref() // nothrow { NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 ); ++weak_count_; NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 ); }