Botan  1.10.17
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

◆ make()

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

Implements Botan::Mutex_Factory.

Definition at line 22 of file mux_pthr.cpp.

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  pthread_mutex_destroy(&mutex);
49  }
50  private:
51  pthread_mutex_t mutex;
52  };
53 
54  return new Pthread_Mutex();
55  }

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