sipxportlib  Version 3.3
OsMutexWnt.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 
12 #ifndef _OsMutexWnt_h_
13 #define _OsMutexWnt_h_
14 
15 // SYSTEM INCLUDES
16 #define WIN32_LEAN_AND_MEAN
17 #include <windows.h>
18 
19 // APPLICATION INCLUDES
20 #include "os/OsMutex.h"
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 
29 // TYPEDEFS
30 typedef HANDLE WinMutex;
31 
32 // FORWARD DECLARATIONS
33 
34 //:Mutual exclusion semaphore (mutex) for Windows NT
35 // The mutual-exclusion semaphore is a specialized version of the binary
36 // semaphore, designed to address issues inherent in mutual exclusion, such
37 // as recursive access to resources, priority inversion, and deletion safety
38 // The fundamental behavior of the mutual-exclusion semaphore is identical to
39 // except for the following restrictions: it can only be used for mutual
40 // exclusion and it can only be released by the task that acquired it.
41 class OsMutexWnt : public OsMutexBase
42 {
43 /* //////////////////////////// PUBLIC //////////////////////////////////// */
44 public:
45 
46 /* ============================ CREATORS ================================== */
47 
48  OsMutexWnt(const unsigned options);
49  //:Constructor
50 
51  virtual
52  ~OsMutexWnt();
53  //:Destructor
54 
55 /* ============================ MANIPULATORS ============================== */
56 
57  virtual OsStatus acquire(const OsTime& rTimeout = OsTime::OS_INFINITY);
58  //:Block the task until the semaphore is acquired or the timeout expires
59 
60  virtual OsStatus tryAcquire(void);
61  //:Conditionally acquire the mutex (i.e., don't block)
62  // Return OS_BUSY if the mutex is held by some other task
63 
64  virtual OsStatus release(void);
65  //:Release the semaphore
66 
67 /* ============================ ACCESSORS ================================= */
68 
69  virtual void OsMutexShow(void);
70  //:Print mutex information to the console.
71 
72 /* ============================ INQUIRY =================================== */
73 
74 /* //////////////////////////// PROTECTED ///////////////////////////////// */
75 protected:
76 
77 /* //////////////////////////// PRIVATE /////////////////////////////////// */
78 private:
79  WinMutex mMutexImp; // Windows NT mutex
80 
81  OsMutexWnt();
82  //:Default constructor (not implemented for this class)
83 
84  OsMutexWnt(const OsMutexWnt& rOsMutexWnt);
85  //:Copy constructor (not implemented for this class)
86 
87  OsMutexWnt& operator=(const OsMutexWnt& rhs);
88  //:Assignment operator (not implemented for this class)
89 
90 };
91 
92 /* ============================ INLINE METHODS ============================ */
93 
94 #endif // _OsMutexWnt_h_
95 
virtual OsStatus acquire(const OsTime &rTimeout=OsTime::OS_INFINITY)
Block the task until the mutex is acquired or the timeout expires.
Definition: OsMutexWnt.cpp:49
virtual ~OsMutexWnt()
Definition: OsMutexWnt.cpp:38
OsStatus
Definition: OsStatus.h:27
Definition: OsMutexWnt.h:41
Mutual exclusion semaphore (mutex)
Definition: OsMutex.h:50
Definition: OsTime.h:45
virtual void OsMutexShow(void)
Print mutex information to the console.
Definition: OsMutexWnt.cpp:73
Definition: OsTime.h:37
virtual OsStatus tryAcquire(void)
Conditionally acquire the mutex (i.e., don&#39;t block)
Definition: OsMutexWnt.cpp:56
HANDLE WinMutex
Definition: OsMutexWnt.h:30
virtual OsStatus release(void)
Release the mutex.
Definition: OsMutexWnt.cpp:62