Botan  1.10.9
Public Member Functions | List of all members
Botan::Pthread_Mutex_Factory Class Reference

#include <mux_pthr.h>

Inheritance diagram for Botan::Pthread_Mutex_Factory:
Botan::Mutex_Factory

Public Member Functions

Mutexmake ()
 

Detailed Description

Pthread Mutex Factory

Definition at line 18 of file mux_pthr.h.

Member Function Documentation

Mutex * Botan::Pthread_Mutex_Factory::make ( )
virtual
Returns
newly allocated mutex

Implements Botan::Mutex_Factory.

Definition at line 22 of file mux_pthr.cpp.

References mutex.

23  {
24 
25  class Pthread_Mutex : public Mutex
26  {
27  public:
28  void lock()
29  {
30  if(pthread_mutex_lock(&mutex) != 0)
31  throw Invalid_State("Pthread_Mutex::lock: Error occured");
32  }
33 
34  void unlock()
35  {
36  if(pthread_mutex_unlock(&mutex) != 0)
37  throw Invalid_State("Pthread_Mutex::unlock: Error occured");
38  }
39 
40  Pthread_Mutex()
41  {
42  if(pthread_mutex_init(&mutex, 0) != 0)
43  throw Invalid_State("Pthread_Mutex: initialization failed");
44  }
45 
46  ~Pthread_Mutex()
47  {
48  if(pthread_mutex_destroy(&mutex) != 0)
49  throw Invalid_State("~Pthread_Mutex: mutex is still locked");
50  }
51  private:
52  pthread_mutex_t mutex;
53  };
54 
55  return new Pthread_Mutex();
56  }
Mutex * mutex
Definition: global_rng.cpp:164

The documentation for this class was generated from the following files: