Nevelex Corporation Nevelex Utilities 1.1.4 09/06/2003
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ObjectPoolManager.h

00001 
00031 /***************************************************************************
00032         ObjectPoolManager.h  -  SINGLETON manager class that handles cleanup of
00033                 expired objects within all object pools.
00034                              -------------------
00035         Author:         Michel Dalal
00036         Date:           Fri Sep 27 2002
00037         Copyright:      (C) 2002-2003 Nevelex Corporation
00038  ***************************************************************************/
00039 
00040 #ifndef OBJECTPOOLMANAGER_H
00041 #define OBJECTPOOLMANAGER_H
00042 
00043 #include <memory>
00044 #if defined(__GNUG__) && (__GNUG__ >= 3)
00045 #include <ext/hash_set>
00046 #else
00047 #include <hash_set>
00048 #endif
00049 #include "ace/Task.h"
00050 #include "ace/Synch.h"
00051 #include "PointerHash.h"
00052 #include "ManagedPool.h"
00053 #include "defines.h"
00054 
00062 namespace nevelex_util
00063 {
00068         typedef HASH_NAMESPACE::hash_set<ManagedPool*, PointerHash<ManagedPool*> > ManagedPoolSet;
00069 
00084         class ObjectPoolManager:
00085                 public ACE_Task<ACE_MT_SYNCH>
00086         {
00087         private:
00089                 ACE_Thread_Mutex mutex;
00090 
00092                 ManagedPoolSet managedPoolSet;
00093 
00098                 ObjectPoolManager();
00099 
00101                 static std::auto_ptr<ObjectPoolManager> SINGLETON;
00102 
00103         public: 
00104                 ~ObjectPoolManager();
00105 
00112                 int open(void*);
00113 
00119                 int close(u_long);
00120 
00126                 int svc();
00127 
00135                 static void addPool(ManagedPool* managedPool);
00136                 
00144                 static void removePool(ManagedPool* managedPool);
00145         };
00146 }       // namespace nevelex_util
00147 
00148 #endif