Make a memory pool that is based on C++ new/delete. This is useful for integrating existing components that use new/delete into the ACE Malloc scheme... More...
#include <Local_Memory_Pool.h>
Public Types | |
typedef ACE_Local_Memory_Pool_Options | OPTIONS |
Public Member Functions | |
ACE_Local_Memory_Pool (const ACE_TCHAR *backing_store_name=0, const OPTIONS *options=0) | |
Initialize the pool. | |
virtual | ~ACE_Local_Memory_Pool (void) |
virtual void * | init_acquire (size_t nbytes, size_t &rounded_bytes, int &first_time) |
Ask system for initial chunk of local memory. | |
virtual void * | acquire (size_t nbytes, size_t &rounded_bytes) |
virtual int | release (int destroy=1) |
Instruct the memory pool to release all of its resources. | |
virtual int | sync (ssize_t len=-1, int flags=MS_SYNC) |
virtual int | sync (void *addr, size_t len, int flags=MS_SYNC) |
virtual int | protect (ssize_t len=-1, int prot=PROT_RDWR) |
virtual int | protect (void *addr, size_t len, int prot=PROT_RDWR) |
virtual int | remap (void *addr) |
virtual void * | base_addr (void) const |
virtual void | dump (void) const |
Dump the state of an object. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Member Functions | |
virtual size_t | round_up (size_t nbytes) |
Protected Attributes | |
ACE_Unbounded_Set< char * > | allocated_chunks_ |
List of memory that we have allocated. |
Make a memory pool that is based on C++ new/delete. This is useful for integrating existing components that use new/delete into the ACE Malloc scheme...
Definition at line 48 of file Local_Memory_Pool.h.
Definition at line 51 of file Local_Memory_Pool.h.
ACE_Local_Memory_Pool::ACE_Local_Memory_Pool | ( | const ACE_TCHAR * | backing_store_name = 0 , |
|
const OPTIONS * | options = 0 | |||
) |
Initialize the pool.
Definition at line 23 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::ACE_Local_Memory_Pool"); }
ACE_Local_Memory_Pool::~ACE_Local_Memory_Pool | ( | void | ) | [virtual] |
Definition at line 29 of file Local_Memory_Pool.cpp.
{ // Free up all memory allocated by this pool. this->release (); }
void * ACE_Local_Memory_Pool::acquire | ( | size_t | nbytes, | |
size_t & | rounded_bytes | |||
) | [virtual] |
Acquire at least nbytes from the memory pool. rounded_bytes is the actual number of bytes allocated.
Definition at line 51 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::acquire"); rounded_bytes = this->round_up (nbytes); char *temp = 0; ACE_NEW_RETURN (temp, char[rounded_bytes], 0); ACE_Auto_Basic_Array_Ptr<char> cp (temp); if (this->allocated_chunks_.insert (cp.get ()) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) insertion into set failed\n")), 0); return cp.release (); }
void * ACE_Local_Memory_Pool::base_addr | ( | void | ) | const [virtual] |
Return the base address of this memory pool, 0 if base_addr never changes.
Definition at line 131 of file Local_Memory_Pool.cpp.
{
return 0;
}
void ACE_Local_Memory_Pool::dump | ( | void | ) | const [virtual] |
Dump the state of an object.
Definition at line 16 of file Local_Memory_Pool.cpp.
{ #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_Local_Memory_Pool::dump"); #endif /* ACE_HAS_DUMP */ }
void * ACE_Local_Memory_Pool::init_acquire | ( | size_t | nbytes, | |
size_t & | rounded_bytes, | |||
int & | first_time | |||
) | [virtual] |
Ask system for initial chunk of local memory.
Definition at line 37 of file Local_Memory_Pool.cpp.
int ACE_Local_Memory_Pool::protect | ( | ssize_t | len = -1 , |
|
int | prot = PROT_RDWR | |||
) | [virtual] |
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.
Definition at line 101 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::protect"); return 0; }
int ACE_Local_Memory_Pool::protect | ( | void * | addr, | |
size_t | len, | |||
int | prot = PROT_RDWR | |||
) | [virtual] |
Change the protection of the pages of the mapped region to prot starting at addr up to len bytes.
Definition at line 108 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::protect"); return 0; }
int ACE_Local_Memory_Pool::release | ( | int | destroy = 1 |
) | [virtual] |
Instruct the memory pool to release all of its resources.
Definition at line 73 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::release"); // Zap the memory we allocated. for (ACE_Unbounded_Set<char *>::iterator i = this->allocated_chunks_.begin (); i != this->allocated_chunks_.end (); ++i) delete [] *i; this->allocated_chunks_.reset (); return 0; }
int ACE_Local_Memory_Pool::remap | ( | void * | addr | ) | [virtual] |
Try to extend the virtual address space so that addr is now covered by the address mapping. Always returns 0 since we can't remap a local memory pool.
Definition at line 124 of file Local_Memory_Pool.cpp.
{ return 0; // Not much can be done. }
size_t ACE_Local_Memory_Pool::round_up | ( | size_t | nbytes | ) | [protected, virtual] |
Implement the algorithm for rounding up the request to an appropriate chunksize.
Definition at line 138 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::round_up"); return ACE::round_to_pagesize (nbytes); }
int ACE_Local_Memory_Pool::sync | ( | ssize_t | len = -1 , |
|
int | flags = MS_SYNC | |||
) | [virtual] |
Sync len bytes of the memory region to the backing store starting at <this->base_addr_>. If len == -1 then sync the whole region.
Definition at line 87 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::sync"); return 0; }
int ACE_Local_Memory_Pool::sync | ( | void * | addr, | |
size_t | len, | |||
int | flags = MS_SYNC | |||
) | [virtual] |
Sync len bytes of the memory region to the backing store starting at add_.
Definition at line 94 of file Local_Memory_Pool.cpp.
{ ACE_TRACE ("ACE_Local_Memory_Pool::sync"); return 0; }
Declare the dynamic allocation hooks.
Definition at line 118 of file Local_Memory_Pool.h.
ACE_Unbounded_Set<char *> ACE_Local_Memory_Pool::allocated_chunks_ [protected] |
List of memory that we have allocated.
Definition at line 122 of file Local_Memory_Pool.h.