#include <Object_Manager.h>
Inheritance diagram for ACE_Object_Manager:
Public Types | |
enum | Preallocated_Object { ACE_FILECACHE_LOCK, ACE_STATIC_OBJECT_LOCK, ACE_PREALLOCATED_OBJECTS } |
enum | Preallocated_Array { ACE_EMPTY_PREALLOCATED_ARRAY, ACE_PREALLOCATED_ARRAYS } |
Public Member Functions | |
virtual int | init (void) |
virtual int | fini (void) |
ACE_Object_Manager (void) | |
~ACE_Object_Manager (void) | |
Static Public Member Functions | |
int | starting_up (void) |
int | shutting_down (void) |
int | at_exit (ACE_Cleanup *object, void *param=0) |
int | at_exit (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param) |
ACE_Sig_Set & | default_mask (void) |
ACE_Object_Manager * | instance (void) |
Static Public Attributes | |
void * | preallocated_object [ACE_PREALLOCATED_OBJECTS] = { 0 } |
Table of preallocated objects. | |
void * | preallocated_array [ACE_PREALLOCATED_ARRAYS] = { 0 } |
Table of preallocated arrays. | |
Private Member Functions | |
int | at_exit_i (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param) |
ACE_Object_Manager (const ACE_Object_Manager &) | |
ACE_Object_Manager & | operator= (const ACE_Object_Manager &) |
Private Attributes | |
ACE_OS_Exit_Info | exit_info_ |
For at_exit support. | |
ACE_Object_Manager_Preallocations * | preallocations_ |
Preallocated objects collection. | |
ACE_Sig_Adapter * | ace_service_config_sig_handler_ |
ACE_Service_Config signal handler. | |
Static Private Attributes | |
ACE_Object_Manager * | instance_ = 0 |
Singleton pointer. | |
Friends | |
class | ACE_Object_Manager_Manager |
The manages cleanup of objects, typically singletons, at program termination. In addition to managing the cleanup of the ACE library, it provides an interface for application to register objects to be cleaned up. This class also shuts down ACE library services, so that they can reclaim their storage, at program termination. It works by creating a static instance whose destructor gets called along with those of all other static objects. Hooks are provided for application code to register objects and arrays for cleanup, e.g., destruction. The order of such cleanup calls is in the reverse order of registration, i.e., that last object/array to register gets cleaned up first. The API includes . That class is contained in a separate file because it is a template class, and some compilers require that template and non-template class definitions appear in separate files. Please see ace/Managed_Object.h for a description of that part of the API. In summary, provides two adapters, the and template classes for adapting objects of any type to be easily managed by the . There are several mechanisms for adapting objects and arrays for cleanup at program termination, in roughly increasing order of ease-of-use: 1) Derive the object's class from . 2) Allow the to both dynamically allocate and deallocate the object. 3) Provide an cleanup hook for the object or array. 4) Allow the to both preallocate the object or array, either statically in global data or dynamically on the heap, when its singleton instance is construction.
There are also several mechanisms for registering objects and arrays for cleanup. In decreasing order of flexibility and complexity (with the exception of the last mechanism):
1) ACE_Object_Manager::at_exit (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param); can be used to register any object or array for any cleanup activity at program termination. 2) ACE_Object_Manager::at_exit (ACE_Cleanup *object, void *param = 0); can be used to register an object for any cleanup activity at program termination. The final mechanism is not general purpose, but can only be used to allocate objects and arrays at program startup: 3) ACE_Managed_Object::get_preallocated_object (ACE_Object_Manager::Preallocated_Object id); and ACE_Managed_Object::get_preallocated_array (ACE_Object_Manager::Preallocated_Array id); can only be used to allocate objects at program startup, either in global data or on the heap (selected at compile time). These are intended to replace static locks, etc. Instead of creating a static instance, one can alternatively be created on the stack of the main program thread. It is created just after entry to ::main (int, char *[]), and before any existing code in that function is executed. To enable this alternative, add #define ACE_HAS_NONSTATIC_OBJECT_MANAGER before including the platform specific config-* file in ace/config.h prior to building the ACE library and your applications. This #define is enabled in some config files that are supplied with ACE.
To ensure a static object manager is used, #undef ACE_HAS_NONSTATIC_OBJECT_MANAGER *after* including the platform specific config-* file. Note that the ACE_Object_Manager _must_ be created before any threads are spawned by the program. If ACE_HAS_NONSTATIC_OBJECT_MANAGER is not #defined, the ACE library creates a static, singleton instance. The instance is placed in global program data, and constructed via a static object constructor. If ACE_HAS_NONSTATIC_OBJECT_MANAGER is #defined, the instance is created on the stack of the main program thread, as noted above.
With ACE_HAS_NONSTATIC_OBJECT_MANAGER enabled, the ACE library has no static objects that require destruction. However, there are two drawbacks to using it: 1) main (int, char *[]) must be declared with arguments, even if they're not used. All of ACE is converted to this, so just applications have to be concerned with it. 2) If there any static objects that depend on those that are cleaned up by the Object_Manager, they'll get cleaned up too late. The ACE tests do not violate this requirement. However, applications may have trouble with it. NOTE on the use of <::exit> -- <::exit> does not destroy automatic objects. Therefore, if ACE_HAS_NONSTATIC_OBJECT_MANAGER is enabled, the instance will *not* be destroyed if <::exit> is called! However, <ACE_OS::exit> will properly destroy the ACE_Object_Manager. It is highly recommended that <ACE_OS::exit> be used instead of <::exit>.
However, <::exit> and <ACE_OS::exit> are tricky to use properly, especially in multithread programs. It is much safer to throw an exception (or simulate that effect) that will be caught by instead of calling exit. Then, can perform any necessary application-specific cleanup and return the status value. In addition, it's usually best to avoid calling <::exit> and <ACE_OS::exit> from threads other than the main thread. Thanks to Jeff Greif <jmg@trivida.com> for pointing out that <::exit> doesn't destroy automatic objects, and for developing the recommendations in this paragraph.
Instead of creating a static , or letting ACE create it on the stack of for you, another alternative is to #define ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER. With that #define, the application must create the ACE_Object_Manager. The recommended way is to call <ACE::init> at the start of the program, and call <ACE::fini> at the end. Alternatively, the application could explicity construct an .
Definition at line 198 of file Object_Manager.h.
|
Unique identifiers for preallocated arrays. Please see ace/Managed_Object.h for information on accessing preallocated arrays.
Definition at line 306 of file Object_Manager.h.
00307 { 00308 /// There currently are no preallocated arrays in the ACE 00309 /// library. If the application doesn't have any, make sure 00310 /// the the preallocated_array size is at least one by declaring 00311 /// this dummy . . . 00312 ACE_EMPTY_PREALLOCATED_ARRAY, 00313 00314 /// Hook for preallocated arrays provided by application. 00315 ACE_APPLICATION_PREALLOCATED_ARRAY_DECLARATIONS 00316 00317 ACE_PREALLOCATED_ARRAYS // This enum value must be last! 00318 }; |
|
Unique identifiers for preallocated objects. Please see ace/Managed_Object.h for information on accessing preallocated objects. Definition at line 277 of file Object_Manager.h.
00278 { 00279 ACE_FILECACHE_LOCK, 00280 #if defined (ACE_HAS_THREADS) 00281 ACE_STATIC_OBJECT_LOCK, 00282 #endif /* ACE_HAS_THREADS */ 00283 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00284 ACE_MT_CORBA_HANDLER_LOCK, 00285 ACE_DUMP_LOCK, 00286 ACE_SIG_HANDLER_LOCK, 00287 ACE_SINGLETON_NULL_LOCK, 00288 ACE_SINGLETON_RECURSIVE_THREAD_LOCK, 00289 ACE_THREAD_EXIT_LOCK, 00290 #if !defined (ACE_LACKS_ACE_TOKEN) 00291 ACE_TOKEN_MANAGER_CREATION_LOCK, 00292 ACE_TOKEN_INVARIANTS_CREATION_LOCK, 00293 #endif /* ! ACE_LACKS_ACE_TOKEN */ 00294 ACE_PROACTOR_EVENT_LOOP_LOCK, 00295 #endif /* ACE_MT_SAFE */ 00296 00297 // Hook for preallocated objects provided by application. 00298 ACE_APPLICATION_PREALLOCATED_OBJECT_DECLARATIONS 00299 00300 ACE_PREALLOCATED_OBJECTS // This enum value must be last! 00301 }; |
|
Definition at line 283 of file Object_Manager.cpp. References ACE_NEW, init(), and instance_.
00286 : exit_info_ () 00287 #if !defined (ACE_LACKS_ACE_SVCCONF) 00288 , preallocations_ (0) 00289 , ace_service_config_sig_handler_ (0) 00290 #endif /* ! ACE_LACKS_ACE_SVCCONF */ 00291 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00292 , singleton_null_lock_ (0) 00293 , singleton_recursive_lock_ (0) 00294 # endif /* ACE_MT_SAFE */ 00295 { 00296 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00297 ACE_NEW (internal_lock_, ACE_Recursive_Thread_Mutex); 00298 # endif /* ACE_MT_SAFE */ 00299 00300 // If instance_ was not 0, then another ACE_Object_Manager has 00301 // already been instantiated (it is likely to be one initialized by way 00302 // of library/DLL loading). Let this one go through construction in 00303 // case there really is a good reason for it (like, ACE is a static/archive 00304 // library, and this one is the non-static instance (with 00305 // ACE_HAS_NONSTATIC_OBJECT_MANAGER, or the user has a good reason for 00306 // creating a separate one) but the original one will be the one retrieved 00307 // from calls to ACE_Object_Manager::instance(). 00308 00309 // Be sure that no further instances are created via instance (). 00310 if (instance_ == 0) 00311 instance_ = this; 00312 00313 init (); 00314 } |
|
Definition at line 316 of file Object_Manager.cpp. References fini().
00317 { 00318 dynamically_allocated_ = 0; // Don't delete this again in fini() 00319 fini (); 00320 } |
|
|
|
Register an object (or array) for cleanup at process termination. "cleanup_hook" points to a (global, or static member) function that is called for the object or array when it to be destroyed. It may perform any necessary cleanup specific for that object or its class. "param" is passed as the second parameter to the "cleanup_hook" function; the first parameter is the object (or array) to be destroyed. "cleanup_hook", for example, may delete the object (or array). For OS's that do not have processes, this function is the same as . Returns 0 on success. On failure, returns -1 and sets errno to: EAGAIN if shutting down, ENOMEM if insufficient virtual memory, or EEXIST if the object (or array) had already been registered. Definition at line 20 of file Object_Manager.inl. References ACE_CLEANUP_FUNC, at_exit_i(), and instance().
00023 { 00024 return ACE_Object_Manager::instance ()->at_exit_i ( 00025 object, 00026 cleanup_hook, 00027 param); 00028 } |
|
Register an ACE_Cleanup object for cleanup at process termination. The object is deleted via the . If you need more flexiblity, see the method below. For OS's that do not have processes, cleanup takes place at the end of . Returns 0 on success. On failure, returns -1 and sets errno to: EAGAIN if shutting down, ENOMEM if insufficient virtual memory, or EEXIST if the object (or array) had already been registered. Definition at line 9 of file Object_Manager.inl. References ACE_CLEANUP_DESTROYER_NAME, ACE_CLEANUP_FUNC, at_exit_i(), and instance(). Referenced by ACE_Token_Manager::instance(), ACE_Token_Invariant_Manager::instance(), ACE_TSS_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Process_Manager::instance(), and ACE_Log_Msg::instance().
00011 { 00012 return ACE_Object_Manager::instance ()->at_exit_i ( 00013 object, 00014 (ACE_CLEANUP_FUNC) ACE_CLEANUP_DESTROYER_NAME, 00015 param); 00016 } |
|
Register an object or array for deletion at program termination. See description of static version above for return values. Definition at line 347 of file Object_Manager.cpp. References ACE_CLEANUP_FUNC, ACE_GUARD_RETURN, ACE_OS_Exit_Info::at_exit_i(), exit_info_, ACE_OS_Exit_Info::find(), instance_, and ACE_Object_Manager_Base::shutting_down_i(). Referenced by at_exit().
00350 { 00351 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 00352 *instance_->internal_lock_, -1)); 00353 00354 if (shutting_down_i ()) 00355 { 00356 errno = EAGAIN; 00357 return -1; 00358 } 00359 00360 if (exit_info_.find (object)) 00361 { 00362 // The object has already been registered. 00363 errno = EEXIST; 00364 return -1; 00365 } 00366 00367 return exit_info_.at_exit_i (object, cleanup_hook, param); 00368 } |
|
Definition at line 32 of file Object_Manager.inl. References ACE_OS_Object_Manager::default_mask().
00033 { 00034 // A safe cast, but this static method shouldn't be used anyways. 00035 // Use ACE_Object_Manager::default_mask () instead. 00036 return 00037 *reinterpret_cast<ACE_Sig_Set *> (ACE_OS_Object_Manager::default_mask ()); 00038 } |
|
Explicitly destroy the singleton instance of the ACE_Object_Manager. Returns 0 on success, -1 on failure, and 1 if it had already been called. Implements ACE_Object_Manager_Base. Definition at line 594 of file Object_Manager.cpp. References ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS, ACE_APPLICATION_PREALLOCATED_OBJECT_DELETIONS, ACE_DELETE_PREALLOCATED_OBJECT, ACE_FILECACHE_LOCK, ace_service_config_sig_handler_, ACE_STATIC_OBJECT_LOCK, ACE_SYNCH_RW_MUTEX, ACE_OS_Exit_Info::call_hooks(), ACE_Static_Object_Lock::cleanup_lock(), ACE_OS::cleanup_tss(), ACE_Service_Config::close(), ACE_Allocator::close_singleton(), ACE_Thread_Manager::close_singleton(), ACE_DLL_Manager::close_singleton(), ACE_Framework_Repository::close_singleton(), exit_info_, ACE_OS_Object_Manager::fini(), ACE_Service_Config::fini_svcs(), ACE_OS_Object_Manager::instance_, instance_, ACE_TOKEN_CONST::MUTEX, preallocations_, ACE_Object_Manager_Base::shutting_down_i(), and ACE_Trace::stop_tracing(). Referenced by ACE::fini(), and ~ACE_Object_Manager().
00595 { 00596 if (shutting_down_i ()) 00597 // Too late. Or, maybe too early. Either fini () has already 00598 // been called, or init () was never called. 00599 return object_manager_state_ == OBJ_MAN_SHUT_DOWN ? 1 : -1; 00600 00601 // No mutex here. Only the main thread should destroy the singleton 00602 // ACE_Object_Manager instance. 00603 00604 // Indicate that this ACE_Object_Manager instance is being 00605 // shut down. 00606 object_manager_state_ = OBJ_MAN_SHUTTING_DOWN; 00607 00608 // Call all registered cleanup hooks, in reverse order of 00609 // registration. 00610 exit_info_.call_hooks (); 00611 00612 if (this == instance_) 00613 { 00614 #if !defined (ACE_LACKS_ACE_SVCCONF) 00615 delete preallocations_; 00616 preallocations_ = 0; 00617 #endif /* ! ACE_LACKS_ACE_SVCCONF */ 00618 00619 #if defined (ACE_HAS_TRACE) 00620 ACE_Trace::stop_tracing (); 00621 #endif /* ACE_HAS_TRACE */ 00622 00623 #if !defined (ACE_LACKS_ACE_SVCCONF) 00624 // Close and possibly delete all service instances in the Service 00625 // Repository. 00626 ACE_Service_Config::fini_svcs (); 00627 00628 // Unlink all services in the Service Repository and close/delete 00629 // all ACE library services and singletons. 00630 ACE_Service_Config::close (); 00631 #endif /* ! ACE_LACKS_ACE_SVCCONF */ 00632 00633 // This must come after closing ACE_Service_Config, since it will 00634 // close down it's dlls--it manages ACE_DLL_Manager. 00635 ACE_Framework_Repository::close_singleton (); 00636 ACE_DLL_Manager::close_singleton (); 00637 00638 # if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) 00639 ACE_Thread_Manager::close_singleton (); 00640 # endif /* ! ACE_THREAD_MANAGER_LACKS_STATICS */ 00641 00642 // Close the main thread's TSS, including its Log_Msg instance. 00643 ACE_OS::cleanup_tss (1 /* main thread */); 00644 00645 // 00646 // Note: Do not access Log Msg after this since it is gone 00647 // 00648 00649 // Close the ACE_Allocator. 00650 ACE_Allocator::close_singleton (); 00651 00652 #if ! defined (ACE_HAS_STATIC_PREALLOCATION) 00653 // Hooks for deletion of preallocated objects and arrays provided by 00654 // application. 00655 ACE_APPLICATION_PREALLOCATED_ARRAY_DELETIONS 00656 ACE_APPLICATION_PREALLOCATED_OBJECT_DELETIONS 00657 00658 // Cleanup the dynamically preallocated arrays. 00659 // (none) 00660 00661 // Cleanup the dynamically preallocated objects. 00662 ACE_DELETE_PREALLOCATED_OBJECT (ACE_SYNCH_RW_MUTEX, ACE_FILECACHE_LOCK) 00663 #if defined (ACE_HAS_THREADS) 00664 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Recursive_Thread_Mutex, 00665 ACE_STATIC_OBJECT_LOCK) 00666 #endif /* ACE_HAS_THREADS */ 00667 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00668 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex, 00669 ACE_MT_CORBA_HANDLER_LOCK) 00670 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex, ACE_DUMP_LOCK) 00671 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Recursive_Thread_Mutex, 00672 ACE_SIG_HANDLER_LOCK) 00673 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Null_Mutex, 00674 ACE_SINGLETON_NULL_LOCK) 00675 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Recursive_Thread_Mutex, 00676 ACE_SINGLETON_RECURSIVE_THREAD_LOCK) 00677 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex, ACE_THREAD_EXIT_LOCK) 00678 #if !defined (ACE_LACKS_ACE_TOKEN) && defined (ACE_HAS_TOKENS_LIBRARY) 00679 ACE_DELETE_PREALLOCATED_OBJECT (ACE_TOKEN_CONST::MUTEX, 00680 ACE_TOKEN_MANAGER_CREATION_LOCK) 00681 ACE_DELETE_PREALLOCATED_OBJECT (ACE_TOKEN_CONST::MUTEX, 00682 ACE_TOKEN_INVARIANTS_CREATION_LOCK) 00683 #endif /* ! ACE_LACKS_ACE_TOKEN && ACE_HAS_TOKENS_LIBRARY */ 00684 ACE_DELETE_PREALLOCATED_OBJECT (ACE_Thread_Mutex, 00685 ACE_PROACTOR_EVENT_LOOP_LOCK) 00686 # endif /* ACE_MT_SAFE */ 00687 #endif /* ! ACE_HAS_STATIC_PREALLOCATION */ 00688 00689 #if defined (ACE_HAS_THREADS) 00690 ACE_Static_Object_Lock::cleanup_lock (); 00691 #endif /* ACE_HAS_THREADS */ 00692 } 00693 00694 #if !defined (ACE_LACKS_ACE_SVCCONF) 00695 delete ace_service_config_sig_handler_; 00696 ace_service_config_sig_handler_ = 0; 00697 #endif /* ! ACE_LACKS_ACE_SVCCONF */ 00698 00699 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00700 delete internal_lock_; 00701 internal_lock_ = 0; 00702 00703 delete singleton_null_lock_; 00704 singleton_null_lock_ = 0; 00705 00706 delete singleton_recursive_lock_; 00707 singleton_recursive_lock_ = 0; 00708 #endif /* ACE_MT_SAFE */ 00709 00710 // Indicate that this ACE_Object_Manager instance has been shut down. 00711 object_manager_state_ = OBJ_MAN_SHUT_DOWN; 00712 00713 // Then, ensure that the ACE_OS_Object_Manager gets shut down. 00714 if (this == instance_ && ACE_OS_Object_Manager::instance_) 00715 ACE_OS_Object_Manager::instance_->fini (); 00716 00717 if (dynamically_allocated_) 00718 { 00719 delete this; 00720 } 00721 00722 if (this == instance_) 00723 instance_ = 0; 00724 00725 return 0; 00726 } |
|
Explicitly initialize (construct the singleton instance of) the ACE_Object_Manager. Returns 0 on success, -1 on failure, and 1 if it had already been called. Implements ACE_Object_Manager_Base. Definition at line 177 of file Object_Manager.cpp. References ACE_APPLICATION_PREALLOCATED_ARRAY_DEFINITIONS, ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS, ACE_FILECACHE_LOCK, ACE_LOG_MSG, ACE_NEW_RETURN, ACE_PREALLOCATE_OBJECT, ace_service_config_sig_handler_, ACE_STATIC_OBJECT_LOCK, ACE_SYNCH_RW_MUTEX, ACE_OS_Object_Manager::instance(), instance_, ACE_TOKEN_CONST::MUTEX, ACE_Object_Manager_Base::next_, preallocations_, ACE_Service_Config::signal_handler(), ACE_Trace::start_tracing(), and ACE_Object_Manager_Base::starting_up_i(). Referenced by ACE_Object_Manager(), and ACE::init().
00178 { 00179 if (starting_up_i ()) 00180 { 00181 // First, indicate that the ACE_Object_Manager instance is being 00182 // initialized. 00183 object_manager_state_ = OBJ_MAN_INITIALIZING; 00184 00185 // Only The Instance sets up with ACE_OS_Object_Manager and initializes 00186 // the preallocated objects. 00187 if (this == instance_) 00188 { 00189 // Make sure that the ACE_OS_Object_Manager has been created, 00190 // and register with it for chained fini (). 00191 ACE_OS_Object_Manager::instance ()->next_ = this; 00192 00193 # if defined (ACE_HAS_BUILTIN_ATOMIC_OP) 00194 ACE_Atomic_Op<ACE_Thread_Mutex, long>::init_functions (); 00195 ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::init_functions (); 00196 # endif /* ACE_HAS_BUILTIN_ATOMIC_OP */ 00197 00198 # if !defined (ACE_LACKS_ACE_SVCCONF) 00199 // Construct the ACE_Service_Config's signal handler. 00200 ACE_NEW_RETURN (ace_service_config_sig_handler_, 00201 ACE_Sig_Adapter (&ACE_Service_Config::handle_signal), -1); 00202 ACE_Service_Config::signal_handler (ace_service_config_sig_handler_); 00203 # endif /* ! ACE_LACKS_ACE_SVCCONF */ 00204 00205 // Allocate the preallocated (hard-coded) object instances. 00206 ACE_PREALLOCATE_OBJECT (ACE_SYNCH_RW_MUTEX, ACE_FILECACHE_LOCK) 00207 # if defined (ACE_HAS_THREADS) 00208 ACE_PREALLOCATE_OBJECT (ACE_Recursive_Thread_Mutex, 00209 ACE_STATIC_OBJECT_LOCK) 00210 # endif /* ACE_HAS_THREADS */ 00211 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00212 ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex, 00213 ACE_MT_CORBA_HANDLER_LOCK) 00214 ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex, ACE_DUMP_LOCK) 00215 ACE_PREALLOCATE_OBJECT (ACE_Recursive_Thread_Mutex, 00216 ACE_SIG_HANDLER_LOCK) 00217 ACE_PREALLOCATE_OBJECT (ACE_Null_Mutex, ACE_SINGLETON_NULL_LOCK) 00218 ACE_PREALLOCATE_OBJECT (ACE_Recursive_Thread_Mutex, 00219 ACE_SINGLETON_RECURSIVE_THREAD_LOCK) 00220 ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex, ACE_THREAD_EXIT_LOCK) 00221 #if !defined (ACE_LACKS_ACE_TOKEN) && defined (ACE_HAS_TOKENS_LIBRARY) 00222 ACE_PREALLOCATE_OBJECT (ACE_TOKEN_CONST::MUTEX, 00223 ACE_TOKEN_MANAGER_CREATION_LOCK) 00224 ACE_PREALLOCATE_OBJECT (ACE_TOKEN_CONST::MUTEX, 00225 ACE_TOKEN_INVARIANTS_CREATION_LOCK) 00226 #endif /* ! ACE_LACKS_ACE_TOKEN && ACE_HAS_TOKENS_LIBRARY */ 00227 ACE_PREALLOCATE_OBJECT (ACE_Thread_Mutex, 00228 ACE_PROACTOR_EVENT_LOOP_LOCK) 00229 # endif /* ACE_MT_SAFE */ 00230 } 00231 00232 if (this == instance_) 00233 { 00234 // Hooks for preallocated objects and arrays provided by application. 00235 ACE_APPLICATION_PREALLOCATED_OBJECT_DEFINITIONS 00236 ACE_APPLICATION_PREALLOCATED_ARRAY_DEFINITIONS 00237 00238 # if defined (ACE_HAS_TSS_EMULATION) 00239 // Initialize the main thread's TS storage. 00240 ACE_TSS_Emulation::tss_open (ts_storage_); 00241 # endif /* ACE_HAS_TSS_EMULATION */ 00242 00243 #if defined (ACE_DISABLE_WIN32_ERROR_WINDOWS) && \ 00244 defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) 00245 #if defined (_DEBUG) && (defined (_MSC_VER) || defined (__INTEL_COMPILER)) 00246 // This will keep the ACE_Assert window 00247 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); 00248 _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR ); 00249 #endif /* _DEBUG && _MSC_VER || __INTEL_COMPILER */ 00250 00251 // And this will catch all unhandled exceptions. 00252 SetUnhandledExceptionFilter (&ACE_UnhandledExceptionFilter); 00253 #endif /* ACE_DISABLE_WIN32_ERROR_WINDOWS && ACE_WIN32 && !ACE_HAS_WINCE */ 00254 00255 00256 # if !defined (ACE_LACKS_ACE_SVCCONF) 00257 ACE_NEW_RETURN (preallocations_, 00258 ACE_Object_Manager_Preallocations, 00259 -1); 00260 # endif /* ! ACE_LACKS_ACE_SVCCONF */ 00261 00262 // Open the main thread's ACE_Log_Msg. 00263 if (0 == ACE_LOG_MSG) 00264 return -1; 00265 } 00266 00267 // Finally, indicate that the ACE_Object_Manager instance has 00268 // been initialized. 00269 object_manager_state_ = OBJ_MAN_INITIALIZED; 00270 00271 #if defined (ACE_HAS_TRACE) 00272 // Allow tracing again (useful if user does init/fini/init) 00273 ACE_Trace::start_tracing (); 00274 #endif /* ACE_HAS_TRACE */ 00275 00276 return 0; 00277 } else { 00278 // Had already initialized. 00279 return 1; 00280 } 00281 } |
|
Accessor to singleton instance. Because static member functions are provided in the interface, this should not be public. However, it is public so that ACE_Managed_Object<TYPE> can access it. Definition at line 323 of file Object_Manager.cpp. References ACE_ASSERT, ACE_NEW_RETURN, ACE_Object_Manager_Base::dynamically_allocated_, and instance_. Referenced by ACE_Object_Manager_Manager::ACE_Object_Manager_Manager(), at_exit(), ACE::fini(), and ACE::init().
00324 { 00325 // This function should be called during construction of static 00326 // instances, or before any other threads have been created in 00327 // the process. So, it's not thread safe. 00328 00329 if (instance_ == 0) 00330 { 00331 ACE_Object_Manager *instance_pointer; 00332 00333 ACE_NEW_RETURN (instance_pointer, 00334 ACE_Object_Manager, 00335 0); 00336 ACE_ASSERT (instance_pointer == instance_); 00337 00338 instance_pointer->dynamically_allocated_ = 1; 00339 00340 return instance_pointer; 00341 } 00342 else 00343 return instance_; 00344 } |
|
|
|
Returns 1 after the ACE_Object_Manager has been destroyed. This flag can be used to determine if the program is in the midst of destroying static objects. (Note that the program might destroy some static objects before this flag can return 1, if ACE_HAS_NONSTATIC_OBJECT_MANAGER is not defined.) Definition at line 151 of file Object_Manager.cpp. References instance_, and ACE_Object_Manager_Base::shutting_down_i(). Referenced by ACE_DLL_Singleton_T< TYPE, ACE_LOCK >::instance(), ACE_Unmanaged_TSS_Singleton< TYPE, ACE_LOCK >::instance(), ACE_TSS_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Unmanaged_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Service_Repository::instance(), ACE_Static_Object_Lock::instance(), ACE_Framework_Repository::instance(), and ACE_Thread_Manager::wait().
00152 { 00153 return ACE_Object_Manager::instance_ ? instance_->shutting_down_i () : 1; 00154 } |
|
Returns 1 before the ACE_Object_Manager has been constructed. This flag can be used to determine if the program is constructing static objects. If no static object spawns any threads, the program will be single-threaded when this flag returns 1. (Note that the program still might construct some static objects when this flag returns 0, if ACE_HAS_NONSTATIC_OBJECT_MANAGER is not defined.) Definition at line 145 of file Object_Manager.cpp. References instance_, and ACE_Object_Manager_Base::starting_up_i(). Referenced by ACE_DLL_Singleton_T< TYPE, ACE_LOCK >::instance(), ACE_Unmanaged_TSS_Singleton< TYPE, ACE_LOCK >::instance(), ACE_TSS_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Unmanaged_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Singleton< TYPE, ACE_LOCK >::instance(), ACE_Service_Repository::instance(), ACE_Static_Object_Lock::instance(), and ACE_Framework_Repository::instance().
00146 { 00147 return ACE_Object_Manager::instance_ ? instance_->starting_up_i () : 1; 00148 } |
|
Definition at line 430 of file Object_Manager.h. |
|
ACE_Service_Config signal handler.
Definition at line 336 of file Object_Manager.h. |
|
For at_exit support.
Definition at line 329 of file Object_Manager.h. Referenced by at_exit_i(), and fini(). |
|
Singleton pointer.
Definition at line 56 of file Object_Manager.cpp. Referenced by ACE_Object_Manager(), at_exit_i(), fini(), init(), instance(), shutting_down(), and starting_up(). |
|
Table of preallocated arrays.
Definition at line 62 of file Object_Manager.cpp. |
|
Table of preallocated objects.
Definition at line 59 of file Object_Manager.cpp. |
|
Preallocated objects collection.
Definition at line 333 of file Object_Manager.h. |