#include <Local_Memory_Pool.h>
Collaboration diagram for ACE_Local_Memory_Pool:
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. |
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.
References ACE_TRACE.
00025 { 00026 ACE_TRACE ("ACE_Local_Memory_Pool::ACE_Local_Memory_Pool"); 00027 }
ACE_Local_Memory_Pool::~ACE_Local_Memory_Pool | ( | void | ) | [virtual] |
Definition at line 29 of file Local_Memory_Pool.cpp.
References release().
00030 { 00031 // Free up all memory allocated by this pool. 00032 this->release (); 00033 }
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.
References ACE_ERROR_RETURN, ACE_NEW_RETURN, ACE_TEXT, ACE_TRACE, ACE_Auto_Basic_Array_Ptr< X >::get(), LM_ERROR, ACE_Auto_Basic_Array_Ptr< X >::release(), and round_up().
Referenced by init_acquire().
00053 { 00054 ACE_TRACE ("ACE_Local_Memory_Pool::acquire"); 00055 rounded_bytes = this->round_up (nbytes); 00056 00057 char *temp = 0; 00058 ACE_NEW_RETURN (temp, 00059 char[rounded_bytes], 00060 0); 00061 00062 ACE_Auto_Basic_Array_Ptr<char> cp (temp); 00063 00064 if (this->allocated_chunks_.insert (cp.get ()) != 0) 00065 ACE_ERROR_RETURN ((LM_ERROR, 00066 ACE_TEXT ("(%P|%t) insertion into set failed\n")), 00067 0); 00068 00069 return cp.release (); 00070 }
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.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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.
References ACE_TRACE.
00017 { 00018 #if defined (ACE_HAS_DUMP) 00019 ACE_TRACE ("ACE_Local_Memory_Pool::dump"); 00020 #endif /* ACE_HAS_DUMP */ 00021 }
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.
References ACE_TRACE, and acquire().
00040 { 00041 ACE_TRACE ("ACE_Local_Memory_Pool::init_acquire"); 00042 // Note that we assume that when ACE_Local_Memory_Pool is used, 00043 // ACE_Malloc's constructor will only get called once. If this 00044 // assumption doesn't hold, we are in deep trouble! 00045 00046 first_time = 1; 00047 return this->acquire (nbytes, rounded_bytes); 00048 }
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.
References ACE_TRACE.
00109 { 00110 ACE_TRACE ("ACE_Local_Memory_Pool::protect"); 00111 return 0; 00112 }
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.
References ACE_TRACE.
00102 { 00103 ACE_TRACE ("ACE_Local_Memory_Pool::protect"); 00104 return 0; 00105 }
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.
References ACE_TRACE, allocated_chunks_, ACE_Unbounded_Set_Ex< T, C >::end(), and ACE_Unbounded_Set_Ex< T, C >::reset().
Referenced by ~ACE_Local_Memory_Pool().
00074 { 00075 ACE_TRACE ("ACE_Local_Memory_Pool::release"); 00076 00077 // Zap the memory we allocated. 00078 for (ACE_Unbounded_Set<char *>::iterator i = this->allocated_chunks_.begin (); 00079 i != this->allocated_chunks_.end (); 00080 ++i) 00081 delete [] *i; 00082 this->allocated_chunks_.reset (); 00083 return 0; 00084 }
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.
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.
References ACE_TRACE, and ACE::round_to_pagesize().
Referenced by acquire().
00139 { 00140 ACE_TRACE ("ACE_Local_Memory_Pool::round_up"); 00141 return ACE::round_to_pagesize (nbytes); 00142 }
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.
References ACE_TRACE.
00095 { 00096 ACE_TRACE ("ACE_Local_Memory_Pool::sync"); 00097 return 0; 00098 }
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.
References ACE_TRACE.
00088 { 00089 ACE_TRACE ("ACE_Local_Memory_Pool::sync"); 00090 return 0; 00091 }
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.
Referenced by release().