ESA JPIP server  0.1
mutex.h
Go to the documentation of this file.
1 #ifndef _IPC_MUTEX_H_
2 #define _IPC_MUTEX_H_
3 
4 
5 #include <pthread.h>
6 #include "ipc_object.h"
7 
8 
9 namespace ipc
10 {
11 
18  class Mutex :public IPCObject
19  {
20  private:
21  pthread_t locker;
22  pthread_mutex_t mutex;
23 
24  public:
28  typedef SHARED_PTR<Mutex> Ptr;
29 
34  virtual bool Init()
35  {
36  return Init(false);
37  }
38 
44  bool Init(bool initial_owner);
45 
53  virtual WaitResult Wait(int time_out = -1);
54 
60  virtual bool Dispose();
61 
66  bool Release();
67  };
68 
69 }
70 
71 
72 #endif /* _IPC_MUTEX_H_ */
IPC object that offers the functionality of a mutex, implemented by means of the pthread mutex API...
Definition: mutex.h:18
virtual bool Dispose()
Release the resources associated to the IPC object and sets the internal status to false...
Definition: mutex.cc:80
Class base of all the IPC classes that has the basic operations (Init, Wait and Dispose) to be overlo...
Definition: ipc_object.h:39
pthread_mutex_t mutex
Mutex information.
Definition: mutex.h:22
SHARED_PTR< Mutex > Ptr
Pointer to a Mutex object.
Definition: mutex.h:28
bool Release()
Releases/unlocks the mutex.
Definition: mutex.cc:65
virtual bool Init()
Initializes the object without locking the mutex.
Definition: mutex.h:34
pthread_t locker
Id. of the thread that locks the mutex.
Definition: mutex.h:21
virtual WaitResult Wait(int time_out=-1)
Performs a wait operation with the object to get it.
Definition: mutex.cc:34
WaitResult
Enumeration of the possible values returned when a wait operation is performed for an IPC object...
Definition: ipc_object.h:16