sipxportlib  Version 3.3
OsMutex.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 
15 #ifndef _OsMutex_h_
16 #define _OsMutex_h_
17 
18 // SYSTEM INCLUDES
19 
20 // APPLICATION INCLUDES
21 #include "os/OsDefs.h"
22 #include "os/OsSyncBase.h"
23 
24 // DEFINES
25 // MACROS
26 // EXTERNAL FUNCTIONS
27 // EXTERNAL VARIABLES
28 // CONSTANTS
29 // STRUCTS
30 // TYPEDEFS
31 // FORWARD DECLARATIONS
32 
50 class OsMutexBase : public OsSyncBase
51 {
52 /* //////////////////////////// PUBLIC //////////////////////////////////// */
53 public:
54 
56  {
57  Q_FIFO = 0x0,
58  Q_PRIORITY = 0x1,
60  DELETE_SAFE = 0x4,
61  INVERSION_SAFE = 0x8
63  };
65 
66 /* ============================ CREATORS ================================== */
67 
68 /* ============================ MANIPULATORS ============================== */
69 
71  virtual OsStatus acquire(const OsTime& rTimeout = OsTime::OS_INFINITY) = 0;
72 
74  virtual OsStatus tryAcquire(void) = 0;
79  virtual OsStatus release(void) = 0;
81 
82 /* ============================ ACCESSORS ================================= */
83 
85  virtual void OsMutexShow(void) = 0;
86 
87 /* ============================ INQUIRY =================================== */
88 
89 /* //////////////////////////// PROTECTED ///////////////////////////////// */
90 protected:
92  OsMutexBase() { };
93 
95  virtual
96  ~OsMutexBase() { };
97 
98 /* //////////////////////////// PRIVATE /////////////////////////////////// */
99 private:
100 
102  OsMutexBase(const OsMutexBase& rOsMutexBase);
103 
105  OsMutexBase& operator=(const OsMutexBase& rhs);
106 
107 };
108 
109 /* ============================ INLINE METHODS ============================ */
110 
115 #if defined(_WIN32)
116 # include "os/Wnt/OsMutexWnt.h"
117  typedef class OsMutexWnt OsMutex;
118 #elif defined(_VXWORKS)
119 # include "os/Vxw/OsMutexVxw.h"
120  typedef class OsMutexVxw OsMutex;
121 #elif defined(__pingtel_on_posix__)
122 # include "os/linux/OsMutexLinux.h"
123  typedef class OsMutexLinux OsMutex;
124 #else
125 # error Unsupported target platform.
126 #endif
127 
128 #endif // _OsMutex_h_
protect a task that owns the mutex from < unexpected deletion
Definition: OsMutex.h:60
Base class for the synchronization mechanisms in the OS abstraction layer.
Definition: OsSyncBase.h:46
virtual void OsMutexShow(void)=0
Print mutex information to the console.
queue blocked tasks based on their priority
Definition: OsMutex.h:59
queue blocked tasks on a first-in, first-out < basis
Definition: OsMutex.h:57
OsStatus
Definition: OsStatus.h:27
virtual ~OsMutexBase()
Destructor.
Definition: OsMutex.h:96
Definition: OsMutexWnt.h:41
OsMutexBase()
Default constructor.
Definition: OsMutex.h:92
Definition: OsMutexLinux.h:37
Mutual exclusion semaphore (mutex)
Definition: OsMutex.h:50
Definition: OsTime.h:45
Definition: OsTime.h:37
MutexOptions
Definition: OsMutex.h:55
virtual OsStatus acquire(const OsTime &rTimeout=OsTime::OS_INFINITY)=0
Block the task until the mutex is acquired or the timeout expires.
virtual OsStatus release(void)=0
Release the mutex.
virtual OsStatus tryAcquire(void)=0
Conditionally acquire the mutex (i.e., don&#39;t block)
protect the system from priority inversion: NOTE < VxWorks requires Q_PRIORITY with this...
Definition: OsMutex.h:62