diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-23 13:48:53 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-23 13:48:53 +0000 |
commit | 8776b6abc5d6979a7560c3724b516311d06a7818 (patch) | |
tree | 3228a035def3ca21ba29d88f930332c38c33961d /ace/Object_Manager.cpp | |
parent | d85070fe8cc362b67dde1de500d2197fbae1d1d8 (diff) | |
download | ATCD-8776b6abc5d6979a7560c3724b516311d06a7818.tar.gz |
ChangeLogTag: Mon Aug 23 08:46:37 1999 David L. Levine <levine@cs.wustl.edu>
Diffstat (limited to 'ace/Object_Manager.cpp')
-rw-r--r-- | ace/Object_Manager.cpp | 82 |
1 files changed, 64 insertions, 18 deletions
diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index a5b09500888..58aa8d754a7 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -154,6 +154,26 @@ ACE_Object_Manager_Preallocations::~ACE_Object_Manager_Preallocations (void) { } +class ACE_Cleanup_Info_Node +{ + // = TITLE + // For maintaining a list of ACE_Cleanup_Info items. + // + // = DESCRIPTION + // For internal use by ACE_Object_Manager. +public: + ACE_Cleanup_Info_Node (void); + ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, + ACE_Cleanup_Info_Node *next); + ~ACE_Cleanup_Info_Node (void); + ACE_Cleanup_Info_Node *insert (const ACE_Cleanup_Info &); +private: + ACE_Cleanup_Info cleanup_info_; + ACE_Cleanup_Info_Node *next_; + + friend class ACE_Object_Manager; +}; + int ACE_Object_Manager::starting_up (void) { @@ -224,7 +244,8 @@ ACE_Object_Manager::init (void) // shouldn't matter, but just in case // ACE_Static_Object_Lock::instance () gets changed . . . ACE_NEW_RETURN (registered_objects_, - ACE_Unbounded_Queue<ACE_Cleanup_Info>, -1); + ACE_Cleanup_Info_Node, + -1); if (this == instance_) { @@ -338,13 +359,11 @@ ACE_Object_Manager::at_exit_i (void *object, } // Check for already in queue, and return 1 if so. - ACE_Cleanup_Info *info = 0; - for (ACE_Unbounded_Queue_Iterator<ACE_Cleanup_Info> - iter (*registered_objects_); - iter.next (info) != 0; - iter.advance ()) + for (ACE_Cleanup_Info_Node *iter = registered_objects_; + iter && iter->next_ != 0; + iter = iter->next_) { - if (info->object_ == object) + if (iter->cleanup_info_.object_ == object) { // The object has already been registered. errno = EEXIST; @@ -357,9 +376,10 @@ ACE_Object_Manager::at_exit_i (void *object, new_info.cleanup_hook_ = cleanup_hook; new_info.param_ = param; - // Returns -1 and sets errno if unable to allocate storage. Enqueue + // Return -1 and sets errno if unable to allocate storage. Enqueue // at the head and dequeue from the head to get LIFO ordering. - return registered_objects_->enqueue_head (new_info); + registered_objects_ = registered_objects_->insert (new_info); + return registered_objects_ == 0 ? -1 : 0; } #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) @@ -606,10 +626,11 @@ ACE_Object_Manager::fini (void) // Call all registered cleanup hooks, in reverse order of // registration. - ACE_Cleanup_Info info; - while (registered_objects_ && - registered_objects_->dequeue_head (info) != -1) + for (ACE_Cleanup_Info_Node *iter = registered_objects_; + iter && iter->next_ != 0; + iter = iter->next_) { + ACE_Cleanup_Info &info = iter->cleanup_info_; if (info.cleanup_hook_ == (ACE_CLEANUP_FUNC) ace_cleanup_destroyer) // The object is an ACE_Cleanup. ace_cleanup_destroyer ((ACE_Cleanup *) info.object_, info.param_); @@ -723,6 +744,37 @@ ACE_Object_Manager::fini (void) } +ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void) + : cleanup_info_ (), + next_ (0) +{ +} + +ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (const ACE_Cleanup_Info &new_info, + ACE_Cleanup_Info_Node *next) + : cleanup_info_ (new_info), + next_ (next) +{ +} + +ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void) +{ + delete next_; +} + +ACE_Cleanup_Info_Node * +ACE_Cleanup_Info_Node::insert (const ACE_Cleanup_Info &new_info) +{ + ACE_Cleanup_Info_Node *new_node; + + ACE_NEW_RETURN (new_node, + ACE_Cleanup_Info_Node (new_info, this), + 0); + + return new_node; +} + + #if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) class ACE_Export ACE_Object_Manager_Manager // = TITLE @@ -857,9 +909,6 @@ ACE_Static_Object_Lock::cleanup_lock (void) # endif /* ACE_MT_SAFE */ template class ACE_Cleanup_Adapter<ACE_SYNCH_RW_MUTEX>; template class ACE_Managed_Object<ACE_SYNCH_RW_MUTEX>; - template class ACE_Unbounded_Queue<ACE_Cleanup_Info>; - template class ACE_Unbounded_Queue_Iterator<ACE_Cleanup_Info>; - template class ACE_Node<ACE_Cleanup_Info>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) # pragma instantiate ACE_Cleanup_Adapter<ACE_Null_Mutex> @@ -873,7 +922,4 @@ ACE_Static_Object_Lock::cleanup_lock (void) # endif /* ACE_MT_SAFE */ # pragma instantiate ACE_Cleanup_Adapter<ACE_SYNCH_RW_MUTEX> # pragma instantiate ACE_Managed_Object<ACE_SYNCH_RW_MUTEX> -# pragma instantiate ACE_Unbounded_Queue<ACE_Cleanup_Info> -# pragma instantiate ACE_Unbounded_Queue_Iterator<ACE_Cleanup_Info> -# pragma instantiate ACE_Node<ACE_Cleanup_Info> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ |