Implement trylock

pull/2098/merge
Isaac Connor 2018-05-03 13:53:32 -04:00
parent 769d4a8693
commit c6fde10766
2 changed files with 4 additions and 0 deletions

View File

@ -61,6 +61,9 @@ Mutex::~Mutex() {
Error("Unable to destroy pthread mutex: %s", strerror(errno));
}
int Mutex::trylock() {
return pthread_mutex_trylock(&mMutex);
}
void Mutex::lock() {
if ( pthread_mutex_lock(&mMutex) < 0 )
throw ThreadException( stringtf( "Unable to lock pthread mutex: %s", strerror(errno) ) );

View File

@ -74,6 +74,7 @@ private:
}
public:
int trylock();
void lock();
void lock( int secs );
void lock( double secs );