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