#include <Static_Object_Lock.h>
Static Public Member Functions | |
ACE_Recursive_Thread_Mutex * | instance (void) |
Static lock access point. | |
void | cleanup_lock (void) |
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 41 of file Static_Object_Lock.h.
|
For use only by ACE_Object_Manager to clean up lock if it what dynamically allocated. Definition at line 839 of file Object_Manager.cpp. References ACE_DES_FREE, ACE_Static_Object_Lock_lock, and ACE_Static_Object_Lock_Type. Referenced by ACE_Object_Manager::fini().
00840 { 00841 # if defined(ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK) 00842 // It was malloc'd, so we need to explicitly call the dtor 00843 // and then free the memory. 00844 ACE_DES_FREE (ACE_Static_Object_Lock_lock, 00845 ACE_OS::free, 00846 ACE_Static_Object_Lock_Type); 00847 # else /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */ 00848 delete ACE_Static_Object_Lock_lock; 00849 # endif /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */ 00850 ACE_Static_Object_Lock_lock = 0; 00851 } |
|
Static lock access point.
Definition at line 793 of file Object_Manager.cpp. References ACE_NEW_RETURN, ACE_Static_Object_Lock_lock, ACE_Static_Object_Lock_Type, ACE_OS::malloc(), ACE_Cleanup_Adapter< TYPE >::object(), ACE_Object_Manager::shutting_down(), and ACE_Object_Manager::starting_up().
00794 { 00795 if (ACE_Object_Manager::starting_up () || 00796 ACE_Object_Manager::shutting_down ()) 00797 { 00798 // The preallocated ACE_STATIC_OBJECT_LOCK has not been 00799 // constructed yet. Therefore, the program is single-threaded 00800 // at this point. Or, the ACE_Object_Manager instance has been 00801 // destroyed, so the preallocated lock is not available. 00802 // Allocate a lock to use, for interface compatibility, though 00803 // there should be no contention on it. 00804 if (ACE_Static_Object_Lock_lock == 0) 00805 { 00806 # if defined (ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK) 00807 // Allocate a buffer with malloc, and then use placement 00808 // new for the object, on the malloc'd buffer. 00809 void *buffer = 00810 ACE_OS::malloc (sizeof (*ACE_Static_Object_Lock_lock)); 00811 if (buffer == 0) 00812 { 00813 return 0; 00814 } 00815 ACE_NEW_RETURN (ACE_Static_Object_Lock_lock, 00816 (buffer) ACE_Static_Object_Lock_Type (), 00817 0); 00818 # else /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */ 00819 ACE_NEW_RETURN (ACE_Static_Object_Lock_lock, 00820 ACE_Cleanup_Adapter<ACE_Recursive_Thread_Mutex>, 00821 0); 00822 # endif /* ! ACE_SHOULD_MALLOC_STATIC_OBJECT_LOCK */ 00823 } 00824 00825 // Can't register with the ACE_Object_Manager here! The lock's 00826 // declaration is visible to the ACE_Object_Manager destructor, 00827 // so it will clean it up as a special case. 00828 00829 return &ACE_Static_Object_Lock_lock->object (); 00830 } 00831 else 00832 // Return the preallocated ACE_STATIC_OBJECT_LOCK. 00833 return 00834 ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::get_preallocated_object 00835 (ACE_Object_Manager::ACE_STATIC_OBJECT_LOCK); 00836 } |