sipxportlib  Version 3.3
OsCSemWnt.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 _OsCSemWnt_h_
12 #define _OsCSemWnt_h_
13 
14 // SYSTEM INCLUDES
15 #define WIN32_LEAN_AND_MEAN
16 #include <windows.h>
17 
18 // APPLICATION INCLUDES
19 #include "os/OsCSem.h"
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 
28 // TYPEDEFS
29 typedef HANDLE WinSemaphore;
30 
31 // FORWARD DECLARATIONS
32 
33 //:Counting semaphore for Windows NT
34 class OsCSemWnt : public OsCSemBase
35 {
36 /* //////////////////////////// PUBLIC //////////////////////////////////// */
37 public:
38 
39 /* ============================ CREATORS ================================== */
40 
41  OsCSemWnt(const int queueOptions, const int maxCount);
42  //:Constructor setting the initial and max semaphore values to maxCount
43 
44  OsCSemWnt(const int queueOptions, const int maxCount, const int initCount);
45  //:Constructor allowing different initial and maximum semaphore values
46 
47  virtual
48  ~OsCSemWnt();
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 semaphore (i.e., don't block)
58  // Return OS_BUSY if the semaphore is held by some other task
59 
60  virtual OsStatus release(void);
61  //:Release the semaphore
62 
63 /* ============================ ACCESSORS ================================= */
64 
65 
66 /* ============================ INQUIRY =================================== */
67 
68 /* //////////////////////////// PROTECTED ///////////////////////////////// */
69 protected:
70 
71 /* //////////////////////////// PRIVATE /////////////////////////////////// */
72 private:
73  WinSemaphore mSemImp; // Windows NT semaphore
74 
75 
76  OsCSemWnt();
77  //:Default constructor (not implemented for this class)
78 
79  OsCSemWnt(const OsCSemWnt& rOsCSemWnt);
80  //:Copy constructor (not implemented for this class)
81 
82  OsCSemWnt& operator=(const OsCSemWnt& rhs);
83  //:Assignment operator (not implemented for this class)
84 
85  void init(void);
86  //:Common initialization shared by all (non-copy) constructors
87 
88 };
89 
90 /* ============================ INLINE METHODS ============================ */
91 
92 #endif // _OsCSemWnt_h_
93 
virtual OsStatus acquire(const OsTime &rTimeout=OsTime::OS_INFINITY)
Block the task until the semaphore is acquired or the timeout expires.
Definition: OsCSemWnt.cpp:74
OsStatus
Definition: OsStatus.h:27
virtual OsStatus release(void)
Release the semaphore.
Definition: OsCSemWnt.cpp:101
Definition: OsTime.h:45
virtual ~OsCSemWnt()
Definition: OsCSemWnt.cpp:61
Definition: OsCSemWnt.h:34
Counting semaphore.
Definition: OsCSem.h:41
Definition: OsTime.h:37
virtual OsStatus tryAcquire(void)
Conditionally acquire the semaphore (i.e., don&#39;t block)
Definition: OsCSemWnt.cpp:88
HANDLE WinSemaphore
Definition: OsCSemWnt.h:29
HANDLE WinSemaphore
Definition: OsBSemWnt.h:30