#include <Malloc_T.h>
Collaboration diagram for ACE_Malloc_T<, ACE_LOCK, ACE_CB >:
Public Types | |
typedef ACE_MEM_POOL | MEMORY_POOL |
typedef ACE_MEM_POOL_OPTIONS | MEMORY_POOL_OPTIONS |
typedef ACE_CB::ACE_Name_Node | NAME_NODE |
typedef ACE_CB::ACE_Malloc_Header | MALLOC_HEADER |
Public Member Functions | |
ACE_Malloc_T (const ACE_TCHAR *pool_name=0) | |
ACE_Malloc_T (const ACE_TCHAR *pool_name, const ACE_TCHAR *lock_name, const ACE_MEM_POOL_OPTIONS *options=0) | |
ACE_Malloc_T (const ACE_TCHAR *pool_name, const ACE_MEM_POOL_OPTIONS *options, ACE_LOCK *lock) | |
~ACE_Malloc_T (void) | |
Destructor. | |
int | ref_counter (void) |
Get Reference counter. | |
int | release (int close=0) |
Release ref counter. | |
int | remove (void) |
Releases resources allocated by this object. | |
void * | malloc (size_t nbytes) |
Allocate nbytes, but don't give them any initial value. | |
void * | calloc (size_t nbytes, char initial_value= '\0') |
Allocate nbytes, giving them initial_value. | |
void * | calloc (size_t n_elem, size_t elem_size, char initial_value= '\0') |
void | free (void *ptr) |
MEMORY_POOL & | memory_pool (void) |
Returns a reference to the underlying memory pool. | |
int | bind (const char *name, void *pointer, int duplicates=0) |
int | trybind (const char *name, void *&pointer) |
int | find (const char *name, void *&pointer) |
int | find (const char *name) |
Returns 0 if name is in the mapping. -1, otherwise. | |
int | unbind (const char *name) |
int | unbind (const char *name, void *&pointer) |
int | sync (ssize_t len=-1, int flags=MS_SYNC) |
int | sync (void *addr, size_t len, int flags=MS_SYNC) |
int | protect (ssize_t len=-1, int prot=PROT_RDWR) |
int | protect (void *addr, size_t len, int prot=PROT_RDWR) |
ssize_t | avail_chunks (size_t size) const |
ACE_LOCK & | mutex (void) |
void | dump (void) const |
Dump the state of an object. | |
void * | base_addr (void) |
Return cb_ptr value. | |
int | bad (void) |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Private Member Functions | |
int | open (void) |
Initialize the Malloc pool. | |
int | shared_bind (const char *name, void *pointer) |
void * | shared_find (const char *name) |
void * | shared_malloc (size_t nbytes) |
Allocate memory. Assumes that locks are held by callers. | |
void | shared_free (void *ptr) |
Deallocate memory. Assumes that locks are held by callers. | |
Private Attributes | |
ACE_CB * | cb_ptr_ |
MEMORY_POOL | memory_pool_ |
Pool of memory used by ACE_Malloc to manage its freestore. | |
ACE_LOCK * | lock_ |
Lock that ensures mutual exclusion for the memory pool. | |
bool | delete_lock_ |
True if destructor should delete the lock. | |
int | bad_flag_ |
Keep track of failure in constructor. | |
Friends | |
class | ACE_Malloc_LIFO_Iterator_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB > |
class | ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB > |
This class can be configured flexibly with different MEMORY_POOL strategies and different types of ACE_LOCK strategies that support the ACE_Thread_Mutex and ACE_Process_Mutex constructor API.
Common MEMORY_POOL strategies to use with this class are:
The MEMORY_POOL class must provide the following methods:
Note that the ACE_Allocator_Adapter class can be used to integrate allocator classes which do not meet the interface requirements of ACE_Malloc_T.
The bind() and find() methods use linear search, so it's not a good idea to use them for managing a large number of entities. If you need to manage a large number of entities, it's recommended that you bind() an ACE_Hash_Map_Manager that resides in shared memory, use find() to locate it, and then store/retrieve the entities in the hash map.
Definition at line 452 of file Malloc_T.h.
|
Definition at line 460 of file Malloc_T.h. |
|
Definition at line 457 of file Malloc_T.h. |
|
Definition at line 458 of file Malloc_T.h. |
|
Definition at line 459 of file Malloc_T.h. Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::shared_bind(). |
|
Initialize ACE_Malloc. This constructor passes pool_name to initialize the memory pool, and uses ACE::basename() to automatically extract out the name used for the underlying lock name (if necessary). Note that pool_name should be located in a directory with the appropriate visibility and protection so that all processes that need to access it can do so. |
|
Initialize ACE_Malloc. This constructor passes pool_name to initialize the memory pool, and uses lock_name to automatically extract out the name used for the underlying lock name (if necessary). In addition, options is passed through to initialize the underlying memory pool. Note that pool_name should be located in a directory with the appropriate visibility and protection so that all processes that need to access it can do so. |
|
Initialize an ACE_Malloc with an external ACE_LOCK. This constructor passes pool_name and options to initialize the memory pool. lock is used as the pool lock, and must be properly set up and ready for use before being passed to this method. |
|
Destructor.
|
|
Returns a count of the number of available chunks that can hold size byte allocations. Function can be used to determine if you have reached a water mark. This implies a fixed amount of allocated memory.
|
|
Bad flag. This operation should be called immediately after the construction of the Malloc object to query whether the object was constructed successfully. If not, the user should invoke
|
|
Return cb_ptr value.
|
|
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. |
|
Allocate n_elem each of size elem_size, giving them initial_value. |
|
Allocate nbytes, giving them initial_value.
Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::calloc(). |
|
Dump the state of an object.
|
|
Returns 0 if name is in the mapping. -1, otherwise.
|
|
Locate name and pass out parameter via pointer. If found, return 0, returns -1 if failure occurs. |
|
Deallocate memory pointed to by ptr, which must have been allocated previously by malloc(). |
|
Allocate nbytes, but don't give them any initial value.
Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::calloc(). |
|
Returns a reference to the underlying memory pool.
|
|
Returns a pointer to the lock used to provide mutual exclusion to an ACE_Malloc allocator. |
|
Initialize the Malloc pool.
Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::ACE_Malloc_T(). |
|
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 |
|
Get Reference counter.
|
|
Release ref counter.
|
|
Releases resources allocated by this object.
Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::release(). |
|
Associate name with pointer. Assumes that locks are held by callers. Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::bind(), and ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::trybind(). |
|
Try to locate name. If found, return the associated ACE_Name_Node, else returns 0 if can't find the name. Assumes that locks are held by callers. Remember to cast the return value to ACE_CB::ACE_Name_Node*. Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::bind(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::find(), and ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::trybind(). |
|
Deallocate memory. Assumes that locks are held by callers.
Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::free(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::open(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::shared_malloc(), and ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::unbind(). |
|
Allocate memory. Assumes that locks are held by callers.
Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::malloc(). |
|
Sync len bytes of the memory region to the backing store starting at |
|
Sync len bytes of the memory region to the backing store starting at |
|
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. |
|
Unbind (remove) one association of name to pointer. Returns the value of pointer in case the caller needs to deallocate memory. If you want to remove all occurrences of name you'll need to call this method multiple times until it fails... |
|
Unbind (remove) the name from the map. Don't return the pointer to the caller. If you want to remove all occurrences of name you'll need to call this method multiple times until it fails... Referenced by ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::unbind(). |
|
Definition at line 456 of file Malloc_T.h. |
|
Definition at line 455 of file Malloc_T.h. |
|
Declare the dynamic allocation hooks.
Definition at line 637 of file Malloc_T.h. |
|
Keep track of failure in constructor.
Definition at line 689 of file Malloc_T.h. |
|
Pointer to the control block that is stored in memory controlled by . Definition at line 677 of file Malloc_T.h. |
|
True if destructor should delete the lock.
Definition at line 686 of file Malloc_T.h. |
|
Lock that ensures mutual exclusion for the memory pool.
Definition at line 683 of file Malloc_T.h. |
|
Pool of memory used by ACE_Malloc to manage its freestore.
Definition at line 680 of file Malloc_T.h. |