Example #1
0
void
tr_lockUnlock( tr_lock * l )
{
    assert( l->depth > 0 );
    assert( tr_areThreadsEqual( l->lockThread, tr_getCurrentThread( ) ) );

    --l->depth;
    assert( l->depth >= 0 );
#ifdef WIN32
    LeaveCriticalSection( &l->lock );
#else
    pthread_mutex_unlock( &l->lock );
#endif
}
Example #2
0
void
tr_lockLock( tr_lock * l )
{
#ifdef WIN32
    EnterCriticalSection( &l->lock );
#else
    pthread_mutex_lock( &l->lock );
#endif
    assert( l->depth >= 0 );
    if( l->depth )
        assert( tr_areThreadsEqual( l->lockThread, tr_getCurrentThread( ) ) );
    l->lockThread = tr_getCurrentThread( );
    ++l->depth;
}
Example #3
0
void
tr_lockUnlock( tr_lock * l )
{
    assert( l->depth > 0 );
    assert( tr_areThreadsEqual( l->lockThread, tr_getCurrentThread( ) ) );

    --l->depth;
    assert( l->depth >= 0 );
#ifdef __BEOS__
    release_sem( l->lock );
#elif defined( WIN32 )
    LeaveCriticalSection( &l->lock );
#else
    pthread_mutex_unlock( &l->lock );
#endif
}
Example #4
0
int
tr_amInThread( const tr_thread * t )
{
    return tr_areThreadsEqual( tr_getCurrentThread( ), t->thread );
}
Example #5
0
int
tr_lockHave( const tr_lock * l )
{
    return ( l->depth > 0 )
           && ( tr_areThreadsEqual( l->lockThread, tr_getCurrentThread( ) ) );
}