sipxportlib  Version 3.3
OsProtectEventMgr.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 _OsProtectEventMgr_h_
13 #define _OsProtectEventMgr_h_
14 
15 // SYSTEM INCLUDES
16 
17 // APPLICATION INCLUDES
18 #include "os/OsDefs.h"
19 #include "os/OsBSem.h"
20 #include "os/OsProtectEvent.h"
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
30 
31 
33 {
34 
35 /* //////////////////////////// PUBLIC //////////////////////////////////// */
36 public:
37 
38 /* ============================ CREATORS ================================== */
39 
41  //:Return a pointer to the OsProtectEventMgr, creating it if necessary
42 
43  virtual
45  //:Destructor
46 
47 /* ============================ MANIPULATORS ============================== */
48 
49  OsProtectedEvent* alloc(int userData = 0);
50  //:Allocate a new OsProtectEvent
51  // Return OS_SUCCESS if allocation is successful
52 
54  //:Release the OsProtectEvent
55  // Return OS_SUCCESS if the OsProtectEvent is released.
56 
57 /* ============================ ACCESSORS ================================= */
58 
59  int allocCnt();
60  //:Return the number of events that are allocated.
61 
62  int availCnt();
63  //:Return the number of events that are available.
64 
65 /* ============================ INQUIRY =================================== */
66 
67 /* //////////////////////////// PROTECTED ///////////////////////////////// */
68 protected:
69  friend class OsProtectEventMgrInit;
70 
71 #if defined(_pingtel_on_posix_)
72  OsProtectEventMgr(int userData = 0, int initialCount = 1000,
73  int softLimit = 2500,
74  int hardLimit = 25000,
75  int increment = 500);
76 #else
77  OsProtectEventMgr(int userData = 0, int initialCount = 200,
78  int softLimit = 500,
79  int hardLimit = 5000,
80  int increment = 50);
81 #endif
82  //:Constructor
83 
84 /* //////////////////////////// PRIVATE /////////////////////////////////// */
85 private:
86 
87  // Static data members used to enforce Singleton behavior
88  static OsProtectEventMgr* spInstance; // pointer to the single instance of
89  // the OsProtectEventMgr class
90  OsBSem mListSem; // semaphore used to protect the list table
91  int mAllocs; // number of allocations
92  int mFrees; // number of freed events
93 
94  int mInitialCount; // initial number of items
95  int mCurrentCount; // current number of items
96  int mSoftLimit; // soft limit, warn when expanding above this
97  int mHardLimit; // hard limit AND length of mpElts
98  int mIncrement; // number to create when expanding
99  int mNext; // index to next element to examine
100 
101  OsProtectedEvent** mpEvents; // array of pointers to contained objects
102 
103  OsProtectEventMgr(const OsProtectEventMgr& rOsProtectEventMgr);
104  //:Copy constructor (not implemented for this class)
105 
106  OsProtectEventMgr& operator=(const OsProtectEventMgr& rhs);
107  //:Assignment operator (not implemented for this class)
108 
109  OsStatus addtoList(unsigned int key, unsigned int pEvent);
110 
111  OsStatus remove(unsigned int key);
112 
113 };
114 
115 /* ============================ INLINE METHODS ============================ */
116 
117 #endif // _OsProtectEventMgr_h_
int allocCnt()
Definition: OsProtectEventMgr.cpp:201
virtual ~OsProtectEventMgr()
Definition: OsProtectEventMgr.cpp:83
int availCnt()
Definition: OsProtectEventMgr.cpp:208
static OsProtectEventMgr * getEventMgr()
Definition: OsProtectEventMgr.cpp:34
OsStatus release(OsProtectedEvent *pEvent)
Definition: OsProtectEventMgr.cpp:186
OsStatus
Definition: OsStatus.h:27
OsProtectEventMgr(int userData=0, int initialCount=200, int softLimit=500, int hardLimit=5000, int increment=50)
Definition: OsProtectEventMgr.cpp:40
OsProtectedEvent * alloc(int userData=0)
Definition: OsProtectEventMgr.cpp:111
OsProtectEventMgr initializer class. Solves the problem with ordering of constructors & destructors...
Definition: OsProtectEventMgrInit.h:40
Definition: OsProtectEventMgr.h:32
Definition: OsProtectEvent.h:22