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

ACE_Static_Object_Lock Class Reference

Provide an interface to access a global lock. More...

#include <Object_Manager.h>

List of all members.

Static Public Methods

ACE_Recursive_Thread_Mutexinstance (void)
 Static lock access point. More...

void cleanup_lock (void)
 For use only by ACE_Object_Manager to clean up lock if it what dynamically allocated. More...


Detailed Description

Provide an interface to access a global lock.

This class is used to serialize the creation of static singleton objects. It really isn't needed any more, because anyone can access ACE_STATIC_OBJECT_LOCK directly. But, it is retained for backward compatibility.

Definition at line 432 of file Object_Manager.h.


Member Function Documentation

void ACE_Static_Object_Lock::cleanup_lock void    [static]
 

For use only by ACE_Object_Manager to clean up lock if it what dynamically allocated.

Definition at line 833 of file Object_Manager.cpp.

References ACE_DES_FREE, and ACE_OS_Memory::free.

Referenced by ACE_Object_Manager::fini.

00834 {
00835 # if defined(ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK)
00836     // It was malloc'd, so we need to explicitly call the dtor
00837     // and then free the memory.
00838     ACE_DES_FREE (ACE_Static_Object_Lock_lock,
00839                   ACE_OS::free,
00840                   ACE_Static_Object_Lock_Type);
00841 # else  /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
00842     delete ACE_Static_Object_Lock_lock;
00843 # endif /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
00844     ACE_Static_Object_Lock_lock = 0;
00845 }

ACE_Recursive_Thread_Mutex * ACE_Static_Object_Lock::instance void    [static]
 

Static lock access point.

Definition at line 787 of file Object_Manager.cpp.

References ACE_NEW_RETURN, ACE_OS_Memory::malloc, ACE_Cleanup_Adapter::object, ACE_Object_Manager::shutting_down, and ACE_Object_Manager::starting_up.

Referenced by ACE_Thread_Manager::close_singleton, ACE_Service_Repository::close_singleton, ACE_Reactor::close_singleton, ACE_Process_Manager::close_singleton, ACE_Proactor::close_singleton, ACE_Allocator::close_singleton, ACE_Framework_Repository::close_singleton, ACE_DLL_Manager::close_singleton, ACE_High_Res_Timer::global_scale_factor, ACE_Thread_Manager::instance, ACE_Service_Repository::instance, ACE_Reactor::instance, ACE_Process_Manager::instance, ACE_Proactor::instance, ACE_Allocator::instance, ACE_Framework_Repository::instance, ACE_DLL_Manager::instance, and ACE_Sock_Connect::ipv6_enabled.

00788 {
00789   if (ACE_Object_Manager::starting_up ()  ||
00790       ACE_Object_Manager::shutting_down ())
00791     {
00792       // The preallocated ACE_STATIC_OBJECT_LOCK has not been
00793       // constructed yet.  Therefore, the program is single-threaded
00794       // at this point.  Or, the ACE_Object_Manager instance has been
00795       // destroyed, so the preallocated lock is not available.
00796       // Allocate a lock to use, for interface compatibility, though
00797       // there should be no contention on it.
00798       if (ACE_Static_Object_Lock_lock == 0)
00799         {
00800 #     if defined (ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK)
00801         // Allocate a buffer with malloc, and then use placement
00802         // new for the object, on the malloc'd buffer.
00803         void *buffer =
00804           ACE_OS::malloc (sizeof (*ACE_Static_Object_Lock_lock));
00805         if (buffer == 0)
00806           {
00807             return 0;
00808           }
00809         ACE_NEW_RETURN (ACE_Static_Object_Lock_lock,
00810                         (buffer) ACE_Static_Object_Lock_Type (),
00811                         0);
00812 #       else   /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
00813         ACE_NEW_RETURN (ACE_Static_Object_Lock_lock,
00814                         ACE_Cleanup_Adapter<ACE_Recursive_Thread_Mutex>,
00815                         0);
00816 #       endif /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */
00817         }
00818 
00819       // Can't register with the ACE_Object_Manager here!  The lock's
00820       // declaration is visible to the ACE_Object_Manager destructor,
00821       // so it will clean it up as a special case.
00822 
00823       return &ACE_Static_Object_Lock_lock->object ();
00824     }
00825   else
00826     // Return the preallocated ACE_STATIC_OBJECT_LOCK.
00827     return
00828       ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object
00829         (ACE_Object_Manager::ACE_STATIC_OBJECT_LOCK);
00830 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:56:36 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002