Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_OS_Exit_Info Class Reference

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

#include <OS.h>

Collaboration diagram for ACE_OS_Exit_Info:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_OS_Exit_Info (void)
 Default constructor. More...

 ~ACE_OS_Exit_Info (void)
 Destructor. More...

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

int find (void *object)
 Look for a registered cleanup hook object. Returns 1 if already registered, 0 if not. More...

void call_hooks ()
 Call all registered cleanup hooks, in reverse order of registration. More...


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 4334 of file OS.h.


Constructor & Destructor Documentation

ACE_OS_Exit_Info::ACE_OS_Exit_Info void   
 

Default constructor.

Definition at line 324 of file OS.cpp.

References ACE_NEW, and registered_objects_.

ACE_OS_Exit_Info::~ACE_OS_Exit_Info void   
 

Destructor.

Definition at line 329 of file OS.cpp.

References registered_objects_.

00330 {
00331   delete registered_objects_;
00332   registered_objects_ = 0;
00333 }


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 336 of file OS.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.

00339 {
00340   ACE_Cleanup_Info new_info;
00341   new_info.object_ = object;
00342   new_info.cleanup_hook_ = cleanup_hook;
00343   new_info.param_ = param;
00344 
00345   // Return -1 and sets errno if unable to allocate storage.  Enqueue
00346   // at the head and dequeue from the head to get LIFO ordering.
00347 
00348   ACE_Cleanup_Info_Node *new_node;
00349 
00350   if ((new_node = registered_objects_->insert (new_info)) == 0)
00351     return -1;
00352   else
00353     {
00354       registered_objects_ = new_node;
00355       return 0;
00356     }
00357 }

void ACE_OS_Exit_Info::call_hooks  
 

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

Definition at line 378 of file OS.cpp.

References ace_cleanup_destroyer, ACE_CLEANUP_FUNC, 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.

00379 {
00380   // Call all registered cleanup hooks, in reverse order of
00381   // registration.
00382   for (ACE_Cleanup_Info_Node *iter = registered_objects_;
00383        iter  &&  iter->next_ != 0;
00384        iter = iter->next_)
00385     {
00386       ACE_Cleanup_Info &info = iter->cleanup_info_;
00387       if (info.cleanup_hook_ == ACE_reinterpret_cast (ACE_CLEANUP_FUNC,
00388                                                       ace_cleanup_destroyer))
00389         // The object is an ACE_Cleanup.
00390         ace_cleanup_destroyer (ACE_reinterpret_cast (ACE_Cleanup *,
00391                                                      info.object_),
00392                                info.param_);
00393       else if (info.object_ == &ace_exit_hook_marker)
00394         // The hook is an ACE_EXIT_HOOK.
00395         (* ACE_reinterpret_cast (ACE_EXIT_HOOK, info.cleanup_hook_)) ();
00396       else
00397         (*info.cleanup_hook_) (info.object_, info.param_);
00398     }
00399 }

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 360 of file OS.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.

00361 {
00362   // Check for already in queue, and return 1 if so.
00363   for (ACE_Cleanup_Info_Node *iter = registered_objects_;
00364        iter  &&  iter->next_ != 0;
00365        iter = iter->next_)
00366     {
00367       if (iter->cleanup_info_.object_ == object)
00368         {
00369           // The object has already been registered.
00370           return 1;
00371         }
00372     }
00373 
00374   return 0;
00375 }


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 4360 of file OS.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 Mon Jun 16 12:51:48 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002