Example #1
0
 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;
 }
Example #2
0
    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;
    }
Example #3
0
    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
    }
Example #4
0
    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();
        }
    }
Example #5
0
    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();
        }
    }
Example #6
0
        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);
            }
        }
Example #7
0
 void add_ref_copy()
 {
     NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
     ++use_count_;
     NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
 }
Example #8
0
 virtual ~sp_counted_base() // nothrow
 {
     NDNBOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 );
 }
Example #9
0
 void weak_add_ref() // nothrow
 {
     NDNBOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
     ++weak_count_;
     NDNBOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
 }