#include <Malloc_Base.h>
Inheritance diagram for ACE_Allocator:
Public Types | |
typedef size_t | size_type |
Unsigned integer type used for specifying memory block lengths. | |
Public Member Functions | |
ACE_Allocator (void) | |
"No-op" constructor (needed to make certain compilers happy). | |
virtual | ~ACE_Allocator (void) |
Virtual destructor. | |
virtual void * | malloc (size_type nbytes)=0 |
Allocate nbytes, but don't give them any initial value. | |
virtual void * | calloc (size_type nbytes, char initial_value= '\0')=0 |
Allocate nbytes, giving them initial_value. | |
virtual void * | calloc (size_type n_elem, size_type elem_size, char initial_value= '\0')=0 |
virtual void | free (void *ptr)=0 |
Free (must have been allocated by <ACE_Allocator::malloc>). | |
virtual int | remove (void)=0 |
Remove any resources associated with this memory manager. | |
virtual int | bind (const char *name, void *pointer, int duplicates=0)=0 |
virtual int | trybind (const char *name, void *&pointer)=0 |
virtual int | find (const char *name, void *&pointer)=0 |
virtual int | find (const char *name)=0 |
Returns 0 if the name is in the mapping. -1, otherwise. | |
virtual int | unbind (const char *name)=0 |
virtual int | unbind (const char *name, void *&pointer)=0 |
virtual int | sync (ssize_t len=-1, int flags=MS_SYNC)=0 |
virtual int | sync (void *addr, size_type len, int flags=MS_SYNC)=0 |
virtual int | protect (ssize_t len=-1, int prot=PROT_RDWR)=0 |
virtual int | protect (void *addr, size_type len, int prot=PROT_RDWR)=0 |
virtual void | dump (void) const=0 |
Dump the state of the object. | |
Static Public Member Functions | |
ACE_Allocator * | instance (void) |
Get pointer to a default ACE_Allocator. | |
ACE_Allocator * | instance (ACE_Allocator *) |
void | close_singleton (void) |
Delete the dynamically allocated Singleton. | |
Static Private Attributes | |
ACE_Allocator * | allocator_ = 0 |
Pointer to a process-wide ACE_Allocator instance. | |
int | delete_allocator_ = 0 |
Must delete the if non-0. |
Definition at line 39 of file Malloc_Base.h.
|
Unsigned integer type used for specifying memory block lengths.
Definition at line 44 of file Malloc_Base.h. |
|
"No-op" constructor (needed to make certain compilers happy).
Definition at line 105 of file Malloc_Allocator.cpp. References ACE_TRACE.
00106 { 00107 ACE_TRACE ("ACE_Allocator::ACE_Allocator"); 00108 } |
|
Virtual destructor.
Definition at line 100 of file Malloc_Allocator.cpp. References ACE_TRACE.
00101 { 00102 ACE_TRACE ("ACE_Allocator::~ACE_Allocator"); 00103 } |
|
Associate name with pointer. If duplicates == 0 then do not allow duplicate name/pointer associations, else if duplicates != 0 then allow duplicate name/pointer assocations. Returns 0 if successfully binds (1) a previously unbound name or (2) duplicates != 0, returns 1 if trying to bind a previously bound name and duplicates == 0, else returns -1 if a resource failure occurs. Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. Referenced by ACE_Configuration_Heap::create_index(). |
|
Allocate each of size elem_size, giving them initial_value. |
|
Allocate nbytes, giving them initial_value.
|
|
Delete the dynamically allocated Singleton.
Definition at line 83 of file Malloc_Allocator.cpp. References ACE_GUARD, ACE_TRACE, allocator_, and delete_allocator_. Referenced by ACE_Object_Manager::fini().
00084 { 00085 ACE_TRACE ("ACE_Allocator::close_singleton"); 00086 00087 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, 00088 *ACE_Static_Object_Lock::instance ())); 00089 00090 if (ACE_Allocator::delete_allocator_) 00091 { 00092 // This should never be executed.... See the 00093 // ACE_Allocator::instance (void) method for an explanation. 00094 delete ACE_Allocator::allocator_; 00095 ACE_Allocator::allocator_ = 0; 00096 ACE_Allocator::delete_allocator_ = 0; 00097 } 00098 } |
|
|
Returns 0 if the name is in the mapping. -1, otherwise.
Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. |
|
Locate name and pass out parameter via pointer. If found, return 0, returns -1 if failure occurs. Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. Referenced by ACE_Configuration_Heap::create_index(). |
|
|
Set pointer to a process-wide ACE_Allocator and return existing pointer. Definition at line 68 of file Malloc_Allocator.cpp. References ACE_GUARD_RETURN, ACE_TRACE, allocator_, and delete_allocator_.
00069 { 00070 ACE_TRACE ("ACE_Allocator::instance"); 00071 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 00072 *ACE_Static_Object_Lock::instance (), 0)); 00073 ACE_Allocator *t = ACE_Allocator::allocator_; 00074 00075 // We can't safely delete it since we don't know who created it! 00076 ACE_Allocator::delete_allocator_ = 0; 00077 00078 ACE_Allocator::allocator_ = r; 00079 return t; 00080 } |
|
Get pointer to a default ACE_Allocator.
Definition at line 20 of file Malloc_Allocator.cpp. References ACE_ASSERT, ACE_GUARD_RETURN, and allocator_. Referenced by ACE_Activation_Queue::ACE_Activation_Queue(), ACE_Array_Base< T >::ACE_Array_Base(), ACE_Double_Linked_List< T >::ACE_Double_Linked_List(), ACE_Ordered_MultiSet< T >::ACE_Ordered_MultiSet(), ACE_Read_Buffer::ACE_Read_Buffer(), ACE_SString::ACE_SString(), ACE_Unbounded_Queue< T >::ACE_Unbounded_Queue(), ACE_Unbounded_Set< T >::ACE_Unbounded_Set(), ACE_Unbounded_Stack< T >::ACE_Unbounded_Stack(), ACE_RB_Tree< EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK >::open(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::open(), ACE_Hash_Multi_Map_Manager< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::open(), and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::open().
00021 { 00022 // ACE_TRACE ("ACE_Allocator::instance"); 00023 00024 if (ACE_Allocator::allocator_ == 0) 00025 { 00026 // Perform Double-Checked Locking Optimization. 00027 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, 00028 *ACE_Static_Object_Lock::instance (), 0)); 00029 00030 if (ACE_Allocator::allocator_ == 0) 00031 { 00032 // Have a seat. We want to avoid ever having to delete the 00033 // ACE_Allocator instance, to avoid shutdown order 00034 // dependencies. ACE_New_Allocator never needs to be 00035 // destroyed: its destructor is empty and its instance 00036 // doesn't have any state. Therefore, sizeof 00037 // ACE_New_Allocator is equal to sizeof void *. It's 00038 // instance just contains a pointer to its virtual function 00039 // table. 00040 // 00041 // So, we allocate space for the ACE_New_Allocator instance 00042 // in the data segment. Because its size is the same as 00043 // that of a pointer, we allocate it as a pointer so that it 00044 // doesn't get constructed statically. We never bother to 00045 // destroy it. 00046 static void *allocator_instance = 0; 00047 00048 // Check this critical assumption. We put it in a variable 00049 // first to avoid stupid compiler warnings that the 00050 // condition may always be true/false. 00051 # if !defined (ACE_NDEBUG) 00052 int assertion = (sizeof allocator_instance == 00053 sizeof (ACE_New_Allocator)); 00054 ACE_ASSERT (assertion); 00055 # endif /* !ACE_NDEBUG */ 00056 00057 // Initialize the allocator_instance by using a placement 00058 // new. 00059 ACE_Allocator::allocator_ = 00060 new (&allocator_instance) ACE_New_Allocator; 00061 } 00062 } 00063 00064 return ACE_Allocator::allocator_; 00065 } |
|
|
Change the protection of the pages of the mapped region to prot starting at addr up to len bytes. |
|
Change the protection of the pages of the mapped region to prot starting at <this->base_addr_> up to len bytes. If len == -1 then change protection of all pages in the mapped region. Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. |
|
Remove any resources associated with this memory manager.
Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. Referenced by ACE_Configuration_Heap::create_index(). |
|
Sync len bytes of the memory region to the backing store starting at addr. |
|
Sync len bytes of the memory region to the backing store starting at Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. Referenced by ACE_Configuration_Heap::new_section(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::rebind_i(), and ACE_Configuration_Heap::~ACE_Configuration_Heap(). |
|
Associate name with pointer. Does not allow duplicate name/pointer associations. Returns 0 if successfully binds (1) a previously unbound name, 1 if trying to bind a previously bound name, or returns -1 if a resource failure occurs. When this call returns pointer's value will always reference the void * that name is associated with. Thus, if the caller needs to use pointer (e.g., to free it) a copy must be maintained by the caller. Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. |
|
Break any association of name. Returns the value of pointer in case the caller needs to deallocate memory. Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. |
|
Unbind (remove) the name from the map. Don't return the pointer to the caller Implemented in ACE_New_Allocator, ACE_Static_Allocator_Base, ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. |
|
Pointer to a process-wide ACE_Allocator instance.
Reimplemented in ACE_Allocator_Adapter< MALLOC >, and ACE_Allocator_Adapter< ACE_Malloc< ACE_MEM_POOL_2, ACE_LOCK > >. Definition at line 22 of file Malloc.cpp. Referenced by close_singleton(), and instance(). |
|
Must delete the if non-0.
Definition at line 27 of file Malloc.cpp. Referenced by close_singleton(), and instance(). |