ACE_OS_Exit_Info Class Reference

Hold Object Manager cleanup (exit) information. More...

#include <Cleanup.h>

Collaboration diagram for ACE_OS_Exit_Info:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_OS_Exit_Info (void)
 Default constructor.

 ~ACE_OS_Exit_Info (void)
 Destructor.

int at_exit_i (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param)
 Use to register a cleanup hook.

int find (void *object)
void call_hooks ()

Private Attributes

ACE_Cleanup_Info_Noderegistered_objects_

Detailed Description

Hold Object Manager cleanup (exit) information.

For internal use by the ACE library, only.

Definition at line 97 of file Cleanup.h.


Constructor & Destructor Documentation

ACE_OS_Exit_Info::ACE_OS_Exit_Info void   ) 
 

Default constructor.

Definition at line 115 of file Cleanup.cpp.

References ACE_NEW, and registered_objects_.

00116 {
00117   ACE_NEW (registered_objects_, ACE_Cleanup_Info_Node);
00118 }

ACE_OS_Exit_Info::~ACE_OS_Exit_Info void   ) 
 

Destructor.

Definition at line 120 of file Cleanup.cpp.

References registered_objects_.

00121 {
00122   delete registered_objects_;
00123   registered_objects_ = 0;
00124 }


Member Function Documentation

int ACE_OS_Exit_Info::at_exit_i void *  object,
ACE_CLEANUP_FUNC  cleanup_hook,
void *  param
 

Use to register a cleanup hook.

Definition at line 127 of file Cleanup.cpp.

References ACE_CLEANUP_FUNC, ACE_Cleanup_Info::cleanup_hook_, ACE_Cleanup_Info_Node::insert(), ACE_Cleanup_Info::object_, ACE_Cleanup_Info::param_, and registered_objects_.

Referenced by ACE_OS_Object_Manager::at_exit(), and ACE_Object_Manager::at_exit_i().

00130 {
00131   ACE_Cleanup_Info new_info;
00132   new_info.object_ = object;
00133   new_info.cleanup_hook_ = cleanup_hook;
00134   new_info.param_ = param;
00135 
00136   // Return -1 and sets errno if unable to allocate storage.  Enqueue
00137   // at the head and dequeue from the head to get LIFO ordering.
00138 
00139   ACE_Cleanup_Info_Node *new_node = 0;
00140 
00141   if ((new_node = registered_objects_->insert (new_info)) == 0)
00142     return -1;
00143   else
00144     {
00145       registered_objects_ = new_node;
00146       return 0;
00147     }
00148 }

void ACE_OS_Exit_Info::call_hooks  ) 
 

Call all registered cleanup hooks, in reverse order of registration.

Definition at line 169 of file Cleanup.cpp.

References ACE_CLEANUP_DESTROYER_NAME, ace_exit_hook_marker, ACE_Cleanup_Info::cleanup_hook_, ACE_Cleanup_Info_Node::cleanup_info_, ACE_Cleanup_Info_Node::next_, ACE_Cleanup_Info::object_, ACE_Cleanup_Info::param_, and registered_objects_.

Referenced by ACE_OS_Object_Manager::fini(), and ACE_Object_Manager::fini().

00170 {
00171   // Call all registered cleanup hooks, in reverse order of
00172   // registration.
00173   for (ACE_Cleanup_Info_Node *iter = registered_objects_;
00174        iter  &&  iter->next_ != 0;
00175        iter = iter->next_)
00176     {
00177       ACE_Cleanup_Info &info = iter->cleanup_info_;
00178       if (info.cleanup_hook_ == reinterpret_cast<ACE_CLEANUP_FUNC> (
00179             ACE_CLEANUP_DESTROYER_NAME))
00180         // The object is an ACE_Cleanup.
00181         ACE_CLEANUP_DESTROYER_NAME (
00182           reinterpret_cast<ACE_Cleanup *> (info.object_),
00183           info.param_);
00184       else if (info.object_ == &ace_exit_hook_marker)
00185         // The hook is an ACE_EXIT_HOOK.
00186         (* reinterpret_cast<ACE_EXIT_HOOK> (info.cleanup_hook_)) ();
00187       else
00188         (*info.cleanup_hook_) (info.object_, info.param_);
00189     }
00190 }

int ACE_OS_Exit_Info::find void *  object  ) 
 

Look for a registered cleanup hook object. Returns 1 if already registered, 0 if not.

Definition at line 151 of file Cleanup.cpp.

References ACE_Cleanup_Info_Node::cleanup_info_, ACE_Cleanup_Info_Node::next_, ACE_Cleanup_Info::object_, and registered_objects_.

Referenced by ACE_Object_Manager::at_exit_i().

00152 {
00153   // Check for already in queue, and return 1 if so.
00154   for (ACE_Cleanup_Info_Node *iter = registered_objects_;
00155        iter  &&  iter->next_ != 0;
00156        iter = iter->next_)
00157     {
00158       if (iter->cleanup_info_.object_ == object)
00159         {
00160           // The object has already been registered.
00161           return 1;
00162         }
00163     }
00164 
00165   return 0;
00166 }


Member Data Documentation

ACE_Cleanup_Info_Node* ACE_OS_Exit_Info::registered_objects_ [private]
 

Keeps track of all registered objects. The last node is only used to terminate the list (it doesn't contain a valid ACE_Cleanup_Info).

Definition at line 123 of file Cleanup.h.

Referenced by ACE_OS_Exit_Info(), at_exit_i(), call_hooks(), find(), and ~ACE_OS_Exit_Info().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:26:10 2006 for ACE by doxygen 1.3.6