00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef ACE_OBJECT_MANAGER_BASE_H
00018 #define ACE_OBJECT_MANAGER_BASE_H
00019 #include  "ace/pre.h"
00020 
00021 #include "ace/config-lite.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif 
00026 
00027 #include  "ace/ACE_export.h"
00028 #include "ace/Cleanup.h"
00029 #include "ace/os_include/sys/os_types.h"
00030 #include "ace/os_include/os_signal.h"
00031 
00032 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 class ACE_Object_Manager;
00035 class ACE_OS_Object_Manager_Manager;
00036 class ACE_TSS_Cleanup;
00037 class ACE_TSS_Emulation;
00038 class ACE_Log_Msg;
00039 class ACE_Thread_Hook;
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 class ACE_Export ACE_Object_Manager_Base
00049 {
00050 protected:
00051 
00052   ACE_Object_Manager_Base (void);
00053 
00054 
00055   virtual ~ACE_Object_Manager_Base (void);
00056 
00057 public:
00058 
00059 
00060 
00061 
00062 
00063   virtual int init (void) = 0;
00064 
00065 
00066 
00067 
00068 
00069 
00070   virtual int fini (void) = 0;
00071 
00072   enum Object_Manager_State
00073     {
00074       OBJ_MAN_UNINITIALIZED = 0,
00075       OBJ_MAN_INITIALIZING,
00076       OBJ_MAN_INITIALIZED,
00077       OBJ_MAN_SHUTTING_DOWN,
00078       OBJ_MAN_SHUT_DOWN
00079     };
00080 
00081 protected:
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091   int starting_up_i (void);
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100   int shutting_down_i (void);
00101 
00102 
00103   Object_Manager_State object_manager_state_;
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111   bool dynamically_allocated_;
00112 
00113 
00114   ACE_Object_Manager_Base *next_;
00115 private:
00116   
00117   ACE_Object_Manager_Base (const ACE_Object_Manager_Base &);
00118   ACE_Object_Manager_Base &operator= (const ACE_Object_Manager_Base &);
00119 };
00120 
00121 extern "C"
00122 void
00123 ACE_OS_Object_Manager_Internal_Exit_Hook (void);
00124 
00125 
00126 
00127 class ACE_Log_Msg;
00128 
00129 class ACE_Export ACE_OS_Object_Manager : public ACE_Object_Manager_Base
00130 {
00131 public:
00132 
00133   virtual int init (void);
00134 
00135 
00136   virtual int fini (void);
00137 
00138 
00139 
00140 
00141 
00142 
00143   static int starting_up (void);
00144 
00145 
00146 
00147   static int shutting_down (void);
00148 
00149 
00150   enum Preallocated_Object
00151     {
00152 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00153       ACE_OS_MONITOR_LOCK,
00154       ACE_TSS_CLEANUP_LOCK,
00155       ACE_LOG_MSG_INSTANCE_LOCK,
00156 #   if defined (ACE_HAS_TSS_EMULATION)
00157       ACE_TSS_KEY_LOCK,
00158 #     if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
00159       ACE_TSS_BASE_LOCK,
00160 #     endif 
00161 #   endif 
00162 # else
00163       
00164       
00165       
00166       ACE_OS_EMPTY_PREALLOCATED_OBJECT,
00167 # endif 
00168 
00169 
00170       ACE_OS_PREALLOCATED_OBJECTS
00171     };
00172 
00173 
00174 
00175   static sigset_t *default_mask (void);
00176 
00177 
00178   static ACE_Thread_Hook *thread_hook (void);
00179 
00180 
00181   static ACE_Thread_Hook *thread_hook (ACE_Thread_Hook *new_thread_hook);
00182 
00183 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00184 
00185   static ACE_SEH_EXCEPT_HANDLER seh_except_selector (void);
00186   static ACE_SEH_EXCEPT_HANDLER seh_except_selector (ACE_SEH_EXCEPT_HANDLER);
00187 
00188   static ACE_SEH_EXCEPT_HANDLER seh_except_handler (void);
00189   static ACE_SEH_EXCEPT_HANDLER seh_except_handler (ACE_SEH_EXCEPT_HANDLER);
00190 #endif 
00191 
00192 public:
00193   
00194 
00195   
00196   
00197   
00198 
00199   ACE_OS_Object_Manager (void);
00200 
00201 
00202   ~ACE_OS_Object_Manager (void);
00203 
00204 
00205   static ACE_OS_Object_Manager *instance (void);
00206 
00207 
00208   int at_exit (ACE_EXIT_HOOK func);
00209 
00210 
00211 
00212   static ACE_OS_Object_Manager *instance_;
00213 
00214 
00215   static void *preallocated_object[ACE_OS_PREALLOCATED_OBJECTS];
00216 
00217 
00218   sigset_t *default_mask_;
00219 
00220 
00221   ACE_Thread_Hook *thread_hook_;
00222 
00223 
00224   ACE_OS_Exit_Info exit_info_;
00225 
00226 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00227 
00228 
00229   ACE_SEH_EXCEPT_HANDLER seh_except_selector_;
00230   ACE_SEH_EXCEPT_HANDLER seh_except_handler_;
00231 #endif 
00232 
00233 
00234   static void print_error_message (unsigned int line_number, const ACE_TCHAR *message);
00235 
00236 
00237   friend class ACE_Object_Manager;
00238   friend class ACE_OS_Object_Manager_Manager;
00239   friend class ACE_TSS_Cleanup;
00240   friend class ACE_TSS_Emulation;
00241   friend class ACE_Log_Msg;
00242   friend void ACE_OS_Object_Manager_Internal_Exit_Hook ();
00243 };
00244 
00245 ACE_END_VERSIONED_NAMESPACE_DECL
00246 
00247 #include  "ace/post.h"
00248 #endif