diff options
Diffstat (limited to 'modules/mux_pthr')
-rw-r--r-- | modules/mux_pthr/mux_pthr.cpp | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/modules/mux_pthr/mux_pthr.cpp b/modules/mux_pthr/mux_pthr.cpp index ec2308fae..ade2005e9 100644 --- a/modules/mux_pthr/mux_pthr.cpp +++ b/modules/mux_pthr/mux_pthr.cpp @@ -14,48 +14,42 @@ namespace Botan { -namespace { - -/************************************************* -* Pthread Mutex * -*************************************************/ -class Pthread_Mutex : public Mutex - { - public: - void lock() - { - if(pthread_mutex_lock(&mutex) != 0) - throw Exception("Pthread_Mutex::lock: Error occured"); - } - - void unlock() - { - if(pthread_mutex_unlock(&mutex) != 0) - throw Exception("Pthread_Mutex::unlock: Error occured"); - } - - Pthread_Mutex() - { - if(pthread_mutex_init(&mutex, 0) != 0) - throw Exception("Pthread_Mutex: initialization failed"); - } - - ~Pthread_Mutex() - { - if(pthread_mutex_destroy(&mutex) != 0) - throw Invalid_State("~Pthread_Mutex: mutex is still locked"); - } - private: - pthread_mutex_t mutex; - }; - -} - /************************************************* * Pthread Mutex Factory * *************************************************/ Mutex* Pthread_Mutex_Factory::make() { + + class Pthread_Mutex : public Mutex + { + public: + void lock() + { + if(pthread_mutex_lock(&mutex) != 0) + throw Exception("Pthread_Mutex::lock: Error occured"); + } + + void unlock() + { + if(pthread_mutex_unlock(&mutex) != 0) + throw Exception("Pthread_Mutex::unlock: Error occured"); + } + + Pthread_Mutex() + { + if(pthread_mutex_init(&mutex, 0) != 0) + throw Exception("Pthread_Mutex: initialization failed"); + } + + ~Pthread_Mutex() + { + if(pthread_mutex_destroy(&mutex) != 0) + throw Invalid_State("~Pthread_Mutex: mutex is still locked"); + } + private: + pthread_mutex_t mutex; + }; + return new Pthread_Mutex(); } |