diff options
Diffstat (limited to 'odb/details/posix/mutex.ixx')
-rw-r--r-- | odb/details/posix/mutex.ixx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/odb/details/posix/mutex.ixx b/odb/details/posix/mutex.ixx new file mode 100644 index 0000000..f362d98 --- /dev/null +++ b/odb/details/posix/mutex.ixx @@ -0,0 +1,39 @@ +// file : odb/details/posix/mutex.ixx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include <odb/details/posix/exceptions.hxx> + +namespace odb +{ + namespace details + { + inline mutex:: + ~mutex () + { + pthread_mutex_destroy (&mutex_); + } + + inline mutex:: + mutex () + { + if (int e = pthread_mutex_init (&mutex_, 0)) + throw posix_exception (e); + } + + inline void mutex:: + lock () + { + if (int e = pthread_mutex_lock (&mutex_)) + throw posix_exception (e); + } + + inline void mutex:: + unlock () + { + if (int e = pthread_mutex_unlock (&mutex_)) + throw posix_exception (e); + } + } +} |