sipxportlib  Version 3.3
OsMutexLinux.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 #ifndef _OsMutexLinux_h_
12 #define _OsMutexLinux_h_
13 
14 // SYSTEM INCLUDES
15 
16 // APPLICATION INCLUDES
17 #include "os/OsMutex.h"
18 #include "os/linux/OsLinuxDefs.h"
19 #include "os/linux/pt_mutex.h"
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 // FORWARD DECLARATIONS
29 
30 //:Mutual exclusion semaphore (mutex) for Linux
31 // The mutual-exclusion semaphore is a specialized version of the binary
32 // semaphore, designed to address issues inherent in mutual exclusion, such
33 // as recursive access to resources, priority inversion, and deletion safety
34 // The fundamental behavior of the mutual-exclusion semaphore is identical to
35 // except for the following restrictions: it can only be used for mutual
36 // exclusion and it can only be released by the task that acquired it.
37 class OsMutexLinux : public OsMutexBase
38 {
39 /* //////////////////////////// PUBLIC //////////////////////////////////// */
40 public:
41 
42 /* ============================ CREATORS ================================== */
43 
44  OsMutexLinux(const unsigned options);
45  //:Constructor
46 
47  virtual
48  ~OsMutexLinux();
49  //:Destructor
50 
51 /* ============================ MANIPULATORS ============================== */
52 
53  virtual OsStatus acquire(const OsTime& rTimeout = OsTime::OS_INFINITY);
54  //:Block the task until the semaphore is acquired or the timeout expires
55 
56  virtual OsStatus tryAcquire(void);
57  //:Conditionally acquire the mutex (i.e., don't block)
58  // Return OS_BUSY if the mutex is held by some other task
59 
60  virtual OsStatus release(void);
61  //:Release the semaphore
62 
63 /* ============================ ACCESSORS ================================= */
64 
65  virtual void OsMutexShow(void);
66  //:Print mutex information to the console.
67 
68 /* ============================ INQUIRY =================================== */
69 
70 /* //////////////////////////// PROTECTED ///////////////////////////////// */
71 protected:
72 
73 /* //////////////////////////// PRIVATE /////////////////////////////////// */
74 private:
75  pt_mutex_t mMutexImp; // Pingtel-Linux mutex
76 
77  OsMutexLinux();
78  //:Default constructor (not implemented for this class)
79 
80  OsMutexLinux(const OsMutexLinux& rOsMutexLinux);
81  //:Copy constructor (not implemented for this class)
82 
83  OsMutexLinux& operator=(const OsMutexLinux& rhs);
84  //:Assignment operator (not implemented for this class)
85 
86 };
87 
88 /* ============================ INLINE METHODS ============================ */
89 
90 #endif // _OsMutexLinux_h_
91 
virtual ~OsMutexLinux()
Definition: OsMutexLinux.cpp:47
#define pt_mutex_t
Definition: pt_mutex.h:35
virtual void OsMutexShow(void)
Print mutex information to the console.
Definition: OsMutexLinux.cpp:123
virtual OsStatus tryAcquire(void)
Conditionally acquire the mutex (i.e., don't block)
Definition: OsMutexLinux.cpp:95
OsStatus
Definition: OsStatus.h:27
Definition: OsMutexLinux.h:37
Mutual exclusion semaphore (mutex)
Definition: OsMutex.h:50
Definition: OsTime.h:45
virtual OsStatus release(void)
Release the mutex.
Definition: OsMutexLinux.cpp:110
Definition: OsTime.h:37
virtual OsStatus acquire(const OsTime &rTimeout=OsTime::OS_INFINITY)
Block the task until the mutex is acquired or the timeout expires.
Definition: OsMutexLinux.cpp:64