#include <Object_Manager_Base.h>


Public Types | |
| enum | Preallocated_Object { ACE_OS_EMPTY_PREALLOCATED_OBJECT, ACE_OS_PREALLOCATED_OBJECTS } |
Unique identifiers for preallocated objects. More... | |
Public Member Functions | |
| virtual int | init (void) |
| Explicitly initialize. | |
| virtual int | fini (void) |
| Explicitly destroy. | |
| ACE_OS_Object_Manager (void) | |
| Constructor. | |
| ~ACE_OS_Object_Manager (void) | |
| Destructor. | |
| int | at_exit (ACE_EXIT_HOOK func, const char *name=0) |
| For <ACE_OS::atexit> support. | |
Static Public Member Functions | |
| static int | starting_up (void) |
| static int | shutting_down (void) |
| static sigset_t * | default_mask (void) |
| static ACE_Thread_Hook * | thread_hook (void) |
| Returns the current thread hook for the process. | |
| static ACE_Thread_Hook * | thread_hook (ACE_Thread_Hook *new_thread_hook) |
| Returns the existing thread hook and assign a <new_thread_hook>. | |
| static ACE_OS_Object_Manager * | instance (void) |
| Accessor to singleton instance. | |
| static void | print_error_message (unsigned int line_number, const ACE_TCHAR *message) |
| For use by init () and fini (), to consolidate error reporting. | |
Public Attributes | |
| sigset_t * | default_mask_ |
| Default signal set used, for example, in ACE_Sig_Guard. | |
| ACE_Thread_Hook * | thread_hook_ |
| Thread hook that's used by this process. | |
| ACE_OS_Exit_Info | exit_info_ |
| For at_exit support. | |
Static Public Attributes | |
| static ACE_OS_Object_Manager * | instance_ = 0 |
| Singleton instance pointer. | |
| static void * | preallocated_object [ACE_OS_PREALLOCATED_OBJECTS] = { 0 } |
| Table of preallocated objects. | |
Friends | |
| class | ACE_Object_Manager |
| This class is for internal use by ACE_OS, etc., only. | |
| class | ACE_OS_Object_Manager_Manager |
| class | ACE_TSS_Cleanup |
| class | ACE_TSS_Emulation |
| class | ACE_Log_Msg |
| void | ACE_OS_Object_Manager_Internal_Exit_Hook () |
Definition at line 129 of file Object_Manager_Base.h.
Unique identifiers for preallocated objects.
| ACE_OS_EMPTY_PREALLOCATED_OBJECT | |
| ACE_OS_PREALLOCATED_OBJECTS |
This enum value must be last! |
Definition at line 150 of file Object_Manager_Base.h.
{
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
ACE_OS_MONITOR_LOCK,
ACE_TSS_CLEANUP_LOCK,
ACE_LOG_MSG_INSTANCE_LOCK,
# if defined (ACE_HAS_TSS_EMULATION)
ACE_TSS_KEY_LOCK,
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
ACE_TSS_BASE_LOCK,
# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
# endif /* ACE_HAS_TSS_EMULATION */
# else
// Without ACE_MT_SAFE, There are no preallocated objects. Make
// sure that the preallocated_array size is at least one by
// declaring this dummy . . .
ACE_OS_EMPTY_PREALLOCATED_OBJECT,
# endif /* ACE_MT_SAFE */
/// This enum value must be last!
ACE_OS_PREALLOCATED_OBJECTS
};
| ACE_OS_Object_Manager::ACE_OS_Object_Manager | ( | void | ) |
Constructor.
Definition at line 85 of file Object_Manager_Base.cpp.
: default_mask_ (0) , thread_hook_ (0) , exit_info_ () #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) , seh_except_selector_ (ACE_SEH_Default_Exception_Selector) , seh_except_handler_ (ACE_SEH_Default_Exception_Handler) #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ { // If instance_ was not 0, then another ACE_OS_Object_Manager has // already been instantiated (it is likely to be one initialized by // way of library/DLL loading). Let this one go through // construction in case there really is a good reason for it (like, // ACE is a static/archive library, and this one is the non-static // instance (with ACE_HAS_NONSTATIC_OBJECT_MANAGER, or the user has // a good reason for creating a separate one) but the original one // will be the one retrieved from calls to // ACE_Object_Manager::instance(). // Be sure that no further instances are created via instance (). if (instance_ == 0) instance_ = this; init (); }
| ACE_OS_Object_Manager::~ACE_OS_Object_Manager | ( | void | ) |
Destructor.
Definition at line 111 of file Object_Manager_Base.cpp.
{
dynamically_allocated_ = false; // Don't delete this again in fini()
fini ();
}
| int ACE_OS_Object_Manager::at_exit | ( | ACE_EXIT_HOOK | func, | |
| const char * | name = 0 | |||
| ) |
For <ACE_OS::atexit> support.
Definition at line 397 of file Object_Manager_Base.cpp.
{
return exit_info_.at_exit_i (&ace_exit_hook_marker,
reinterpret_cast <ACE_CLEANUP_FUNC> (func),
0,
name);
}
| sigset_t * ACE_OS_Object_Manager::default_mask | ( | void | ) | [static] |
Accesses a default signal set used, for example, in ACE_Sig_Guard methods.
Definition at line 118 of file Object_Manager_Base.cpp.
{
return ACE_OS_Object_Manager::instance ()->default_mask_;
}
| int ACE_OS_Object_Manager::fini | ( | void | ) | [virtual] |
Explicitly destroy.
Implements ACE_Object_Manager_Base.
Definition at line 285 of file Object_Manager_Base.cpp.
{
if (instance_ == 0 || shutting_down_i ())
// Too late. Or, maybe too early. Either fini () has already
// been called, or init () was never called.
return object_manager_state_ == OBJ_MAN_SHUT_DOWN ? 1 : -1;
// No mutex here. Only the main thread should destroy the singleton
// ACE_OS_Object_Manager instance.
// Indicate that the ACE_OS_Object_Manager instance is being shut
// down. This object manager should be the last one to be shut
// down.
object_manager_state_ = OBJ_MAN_SHUTTING_DOWN;
// If another Object_Manager has registered for termination, do it.
if (next_)
{
next_->fini ();
next_ = 0; // Protect against recursive calls.
}
// Call all registered cleanup hooks, in reverse order of
// registration.
exit_info_.call_hooks ();
// Only clean up preallocated objects when the singleton Instance is being
// destroyed.
if (this == instance_)
{
// Close down Winsock (no-op on other platforms).
ACE_OS::socket_fini ();
#if ! defined (ACE_HAS_STATIC_PREALLOCATION)
// Cleanup the dynamically preallocated objects.
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
if (ACE_OS::thread_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_OS_MONITOR_LOCK"));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_thread_mutex_t,
ACE_OS_MONITOR_LOCK)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
if (ACE_OS::recursive_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_TSS_CLEANUP_LOCK"));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_CLEANUP_LOCK)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
if (ACE_OS::thread_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object [ACE_LOG_MSG_INSTANCE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK "));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_thread_mutex_t,
ACE_LOG_MSG_INSTANCE_LOCK)
# if defined (ACE_HAS_TSS_EMULATION)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
if (ACE_OS::recursive_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_TSS_KEY_LOCK"));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_KEY_LOCK)
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
# if !defined(ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK)
if (ACE_OS::recursive_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_TSS_BASE_LOCK"));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
ACE_OS_DELETE_PREALLOCATED_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_BASE_LOCK)
# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
# endif /* ACE_HAS_TSS_EMULATION */
# if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
ACE_CE_Errno::fini ();
# endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
# endif /* ACE_MT_SAFE */
#endif /* ! ACE_HAS_STATIC_PREALLOCATION */
}
delete default_mask_;
default_mask_ = 0;
// Indicate that this ACE_OS_Object_Manager instance has been shut down.
object_manager_state_ = OBJ_MAN_SHUT_DOWN;
if (dynamically_allocated_)
{
delete this;
}
if (this == instance_)
instance_ = 0;
return 0;
}
| int ACE_OS_Object_Manager::init | ( | void | ) | [virtual] |
Explicitly initialize.
Implements ACE_Object_Manager_Base.
Definition at line 200 of file Object_Manager_Base.cpp.
{
if (starting_up_i ())
{
// First, indicate that this ACE_OS_Object_Manager instance is being
// initialized.
object_manager_state_ = OBJ_MAN_INITIALIZING;
if (this == instance_)
{
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
# if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
ACE_CE_Errno::init ();
# endif /* ACE_HAS_WINCE_BROKEN_ERRNO */
ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t, ACE_OS_MONITOR_LOCK)
if (ACE_OS::thread_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_OS_MONITOR_LOCK"));
ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_CLEANUP_LOCK)
if (ACE_OS::recursive_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_TSS_CLEANUP_LOCK"));
ACE_OS_PREALLOCATE_OBJECT (ACE_thread_mutex_t,
ACE_LOG_MSG_INSTANCE_LOCK)
if (ACE_OS::thread_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_LOG_MSG_INSTANCE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK"));
# if defined (ACE_HAS_TSS_EMULATION)
ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_KEY_LOCK)
if (ACE_OS::recursive_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_KEY_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_TSS_KEY_LOCK"));
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE)
ACE_OS_PREALLOCATE_OBJECT (ACE_recursive_thread_mutex_t,
ACE_TSS_BASE_LOCK)
if (ACE_OS::recursive_mutex_init
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_BASE_LOCK])) != 0)
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_TSS_BASE_LOCK"));
# endif /* ACE_HAS_THREAD_SPECIFIC_STORAGE */
# endif /* ACE_HAS_TSS_EMULATION */
# endif /* ACE_MT_SAFE */
// Open Winsock (no-op on other platforms).
ACE_OS::socket_init (ACE_WSOCK_VERSION);
// Register the exit hook, for use by ACE_OS::exit ().
ACE_OS::set_exit_hook (&ACE_OS_Object_Manager_Internal_Exit_Hook);
}
ACE_NEW_RETURN (default_mask_, sigset_t, -1);
ACE_OS::sigfillset (default_mask_);
// Finally, indicate that the ACE_OS_Object_Manager instance has
// been initialized.
object_manager_state_ = OBJ_MAN_INITIALIZED;
# if defined (ACE_WIN32)
ACE_OS::win32_versioninfo_.dwOSVersionInfoSize =
sizeof (ACE_TEXT_OSVERSIONINFO);
ACE_TEXT_GetVersionEx (&ACE_OS::win32_versioninfo_);
# endif /* ACE_WIN32 */
return 0;
} else {
// Had already initialized.
return 1;
}
}
| ACE_OS_Object_Manager * ACE_OS_Object_Manager::instance | ( | void | ) | [static] |
Accessor to singleton instance.
Definition at line 175 of file Object_Manager_Base.cpp.
{
// This function should be called during construction of static
// instances, or before any other threads have been created in the
// process. So, it's not thread safe.
if (instance_ == 0)
{
ACE_OS_Object_Manager *instance_pointer = 0;
ACE_NEW_RETURN (instance_pointer,
ACE_OS_Object_Manager,
0);
// I (coryan) removed it, using asserts in the OS layer
// brings down the Log msg stuff
// ACE_ASSERT (instance_pointer == instance_);
instance_pointer->dynamically_allocated_ = true;
}
return instance_;
}
| void ACE_OS_Object_Manager::print_error_message | ( | unsigned int | line_number, | |
| const ACE_TCHAR * | message | |||
| ) | [static] |
For use by init () and fini (), to consolidate error reporting.
Definition at line 406 of file Object_Manager_Base.cpp.
{
// To avoid duplication of these const strings in OS.o.
#if !defined (ACE_HAS_WINCE)
fprintf (stderr, "ace/Object_Manager_Base.cpp, line %u: %s ",
line_number,
ACE_TEXT_ALWAYS_CHAR (message));
perror ("failed");
#else
// @@ Need to use the following information.
ACE_UNUSED_ARG (line_number);
ACE_UNUSED_ARG (message);
ACE_TCHAR *lpMsgBuf = 0;
::FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
0,
::GetLastError (),
MAKELANGID (LANG_NEUTRAL,
SUBLANG_DEFAULT),
// Default language
(ACE_TCHAR *) &lpMsgBuf,
0,
0);
::MessageBox (0,
lpMsgBuf,
ACE_TEXT ("ACE_OS error"),
MB_OK);
#endif
}
| int ACE_OS_Object_Manager::shutting_down | ( | void | ) | [static] |
Returns 1 after the ACE_OS_Object_Manager has been destroyed. See <ACE_Object_Manager::shutting_down> for more information.
Definition at line 447 of file Object_Manager_Base.cpp.
{
return ACE_OS_Object_Manager::instance_
? instance_->shutting_down_i ()
: 1;
}
| int ACE_OS_Object_Manager::starting_up | ( | void | ) | [static] |
Returns 1 before the ACE_OS_Object_Manager has been constructed. See <ACE_Object_Manager::starting_up> for more information.
Definition at line 439 of file Object_Manager_Base.cpp.
{
return ACE_OS_Object_Manager::instance_
? instance_->starting_up_i ()
: 1;
}
| ACE_Thread_Hook * ACE_OS_Object_Manager::thread_hook | ( | void | ) | [static] |
Returns the current thread hook for the process.
Definition at line 124 of file Object_Manager_Base.cpp.
{
return ACE_OS_Object_Manager::instance ()->thread_hook_;
}
| ACE_Thread_Hook * ACE_OS_Object_Manager::thread_hook | ( | ACE_Thread_Hook * | new_thread_hook | ) | [static] |
Returns the existing thread hook and assign a <new_thread_hook>.
Definition at line 166 of file Object_Manager_Base.cpp.
{
ACE_OS_Object_Manager *os_om = ACE_OS_Object_Manager::instance ();
ACE_Thread_Hook *old_hook = os_om->thread_hook_;
os_om->thread_hook_ = new_thread_hook;
return old_hook;
}
friend class ACE_Log_Msg [friend] |
Definition at line 241 of file Object_Manager_Base.h.
friend class ACE_Object_Manager [friend] |
This class is for internal use by ACE_OS, etc., only.
Definition at line 237 of file Object_Manager_Base.h.
| void ACE_OS_Object_Manager_Internal_Exit_Hook | ( | ) | [friend] |
Definition at line 74 of file Object_Manager_Base.cpp.
{
if (ACE_OS_Object_Manager::instance_)
ACE_OS_Object_Manager::instance ()->fini ();
}
friend class ACE_OS_Object_Manager_Manager [friend] |
Definition at line 238 of file Object_Manager_Base.h.
friend class ACE_TSS_Cleanup [friend] |
Definition at line 239 of file Object_Manager_Base.h.
friend class ACE_TSS_Emulation [friend] |
Definition at line 240 of file Object_Manager_Base.h.
| sigset_t* ACE_OS_Object_Manager::default_mask_ |
Default signal set used, for example, in ACE_Sig_Guard.
Definition at line 218 of file Object_Manager_Base.h.
For at_exit support.
Definition at line 224 of file Object_Manager_Base.h.
ACE_OS_Object_Manager * ACE_OS_Object_Manager::instance_ = 0 [static] |
Singleton instance pointer.
Definition at line 212 of file Object_Manager_Base.h.
void * ACE_OS_Object_Manager::preallocated_object = { 0 } [static] |
Table of preallocated objects.
Definition at line 215 of file Object_Manager_Base.h.
Thread hook that's used by this process.
Definition at line 221 of file Object_Manager_Base.h.
1.7.0