sipxportlib  Version 3.3
OsBSem.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 _OsBSem_h_
16 #define _OsBSem_h_
17 
18 // SYSTEM INCLUDES
19 // APPLICATION INCLUDES
20 #include "os/OsDefs.h"
21 #include "os/OsSyncBase.h"
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 // FORWARD DECLARATIONS
31 
33 class OsBSemBase : public OsSyncBase
34 {
35 /* //////////////////////////// PUBLIC //////////////////////////////////// */
36 public:
37 
39  {
40  EMPTY = 0,
41  FULL = 1
42  };
43 
45  {
46  Q_FIFO = 0x0,
47  Q_PRIORITY = 0x1
48  };
49 
50 /* ============================ CREATORS ================================== */
51 
52 /* ============================ MANIPULATORS ============================== */
53 
55  virtual OsStatus acquire(const OsTime& rTimeout = OsTime::OS_INFINITY) = 0;
56 
58  virtual OsStatus tryAcquire(void) = 0;
63  virtual OsStatus release(void) = 0;
65 
66 /* ============================ ACCESSORS ================================= */
67 
69  virtual void OsBSemShow(void) = 0;
70 
71 /* ============================ INQUIRY =================================== */
72 
73 /* //////////////////////////// PROTECTED ///////////////////////////////// */
74 protected:
75  int mOptions;
76 
77  int mTaskId;
78 
81  OsBSemBase() { };
82 
84  virtual
85  ~OsBSemBase() { };
86 
87 /* //////////////////////////// PRIVATE /////////////////////////////////// */
88 private:
89 
91  OsBSemBase(const OsBSemBase& rOsBSemBase);
92 
94  OsBSemBase& operator=(const OsBSemBase& rhs);
95 
96 };
97 
98 /* ============================ INLINE METHODS ============================ */
99 
104 #if defined(_WIN32)
105 # include "os/Wnt/OsBSemWnt.h"
106  typedef class OsBSemWnt OsBSem;
107 #elif defined(_VXWORKS)
108 # include "os/Vxw/OsBSemVxw.h"
109  typedef class OsBSemVxw OsBSem;
110 #elif defined(__pingtel_on_posix__)
111 # include "os/linux/OsBSemLinux.h"
112  typedef class OsBSemLinux OsBSem;
113 #else
114 # error Unsupported target platform.
115 #endif
116 
117 #endif // _OsBSem_h_
OsBSemBase()
Default constructor.
Definition: OsBSem.h:81
Base class for the synchronization mechanisms in the OS abstraction layer.
Definition: OsSyncBase.h:46
InitialSemaphoreState
Definition: OsBSem.h:38
virtual OsStatus acquire(const OsTime &rTimeout=OsTime::OS_INFINITY)=0
Block the task until the semaphore is acquired or the timeout expires.
virtual OsStatus tryAcquire(void)=0
Conditionally acquire the semaphore (i.e., don't block)
virtual void OsBSemShow(void)=0
Print semaphore information to the console.
OsStatus
Definition: OsStatus.h:27
virtual ~OsBSemBase()
Destructor.
Definition: OsBSem.h:85
queue blocked tasks on a first-in, first-out basis
Definition: OsBSem.h:46
Definition: OsTime.h:45
semaphore is initially unavailable
Definition: OsBSem.h:40
Definition: OsBSemLinux.h:31
Definition: OsBSemWnt.h:35
virtual OsStatus release(void)=0
Release the semaphore.
queue blocked tasks based on their priority
Definition: OsBSem.h:47
Definition: OsTime.h:37
int mOptions
options specified at time of binary semaphore creation
Definition: OsBSem.h:75
int mTaskId
if OS_SYNC_DEBUG is enabled, ONLY ON WNT, we use this < variable to store the ID of the task currentl...
Definition: OsBSem.h:77
semaphore is initially available
Definition: OsBSem.h:41
QueueOptions
Definition: OsBSem.h:44
Binary semaphore.
Definition: OsBSem.h:33