12345678910111213141516171819202122232425262728 |
- //
- // $Id$
- //
- #include<__vic/posix/mutex.h>
- #include<__vic/throw_errno.h>
- #include<cerrno>
- namespace __vic { namespace posix {
- //----------------------------------------------------------------------------
- void mutex::lock()
- {
- int res = ::pthread_mutex_lock(&mtx);
- if(res) throw_errno("pthread_mutex_lock", res);
- }
- //----------------------------------------------------------------------------
- bool mutex::try_lock()
- {
- int res = ::pthread_mutex_trylock(&mtx);
- if(res == EBUSY) return false;
- if(res) throw_errno("pthread_mutex_trylock", res);
- return true;
- }
- //----------------------------------------------------------------------------
- }} // namespace
|