ACE_Sbrk_Memory_Pool Class Reference

Make a memory pool that is based on <sbrk(2)>. More...

#include <Sbrk_Memory_Pool.h>

List of all members.

Public Types

typedef ACE_Sbrk_Memory_Pool_Options OPTIONS

Public Member Functions

 ACE_Sbrk_Memory_Pool (const ACE_TCHAR *backing_store_name=0, const OPTIONS *options=0)
 Initialize the pool.

virtual ~ACE_Sbrk_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 void dump (void) const
 Dump the state of an object.

virtual void * base_addr (void) const

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

virtual size_t round_up (size_t nbytes)


Detailed Description

Make a memory pool that is based on <sbrk(2)>.

Definition at line 50 of file Sbrk_Memory_Pool.h.


Member Typedef Documentation

typedef ACE_Sbrk_Memory_Pool_Options ACE_Sbrk_Memory_Pool::OPTIONS
 

Definition at line 53 of file Sbrk_Memory_Pool.h.


Constructor & Destructor Documentation

ACE_Sbrk_Memory_Pool::ACE_Sbrk_Memory_Pool const ACE_TCHAR backing_store_name = 0,
const OPTIONS options = 0
 

Initialize the pool.

Definition at line 97 of file Sbrk_Memory_Pool.cpp.

References ACE_TCHAR, and ACE_TRACE.

00099 {
00100   ACE_TRACE ("ACE_Sbrk_Memory_Pool::ACE_Sbrk_Memory_Pool");
00101 }

ACE_Sbrk_Memory_Pool::~ACE_Sbrk_Memory_Pool void   )  [virtual]
 

Definition at line 103 of file Sbrk_Memory_Pool.cpp.

00104 {
00105 }


Member Function Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void * ACE_Sbrk_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 18 of file Sbrk_Memory_Pool.cpp.

References ACE_ERROR_RETURN, ACE_TRACE, LM_ERROR, MAP_FAILED, round_up(), and ACE_OS::sbrk().

Referenced by init_acquire().

00020 {
00021   ACE_TRACE ("ACE_Sbrk_Memory_Pool::acquire");
00022   rounded_bytes = this->round_up (nbytes);
00023   // ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%P|%t) acquiring more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes));
00024   void *cp = ACE_OS::sbrk (rounded_bytes);
00025 
00026   if (cp == MAP_FAILED)
00027     ACE_ERROR_RETURN ((LM_ERROR,
00028                        "(%P|%t) cp = %u\n",
00029                        cp),
00030                       0);
00031   else
00032     // ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%P|%t) acquired more chunks, nbytes = %d, rounded_bytes = %d, new break = %u\n"), nbytes, rounded_bytes, cp));
00033   return cp;
00034 }

void * ACE_Sbrk_Memory_Pool::base_addr void   )  const [virtual]
 

Return the base address of this memory pool, 0 if base_addr never changes.

Definition at line 108 of file Sbrk_Memory_Pool.cpp.

00109 {
00110   return 0;
00111 }

void ACE_Sbrk_Memory_Pool::dump void   )  const [virtual]
 

Dump the state of an object.

Definition at line 90 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE.

00091 {
00092 #if defined (ACE_HAS_DUMP)
00093   ACE_TRACE ("ACE_Sbrk_Memory_Pool::dump");
00094 #endif /* ACE_HAS_DUMP */
00095 }

void * ACE_Sbrk_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 76 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE, and acquire().

00079 {
00080   ACE_TRACE ("ACE_Sbrk_Memory_Pool::init_acquire");
00081   // Note that we assume that when ACE_Sbrk_Memory_Pool is used,
00082   // ACE_Malloc's constructor will only get called once.  If this
00083   // assumption doesn't hold, we are in deep trouble!
00084 
00085   first_time = 1;
00086   return this->acquire (nbytes, rounded_bytes);
00087 }

int ACE_Sbrk_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 67 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE.

00068 {
00069   ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
00070   return 0;
00071 }

int ACE_Sbrk_Memory_Pool::protect ssize_t  len = -1,
int  prot = PROT_RDWR
[virtual]
 

Change the protection of the pages of the mapped region to 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 60 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE, and ssize_t.

00061 {
00062   ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
00063   return 0;
00064 }

int ACE_Sbrk_Memory_Pool::release int  destroy = 1  )  [virtual]
 

Instruct the memory pool to release all of its resources.

Definition at line 39 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE.

00040 {
00041   ACE_TRACE ("ACE_Sbrk_Memory_Pool::release");
00042   return 0;
00043 }

size_t ACE_Sbrk_Memory_Pool::round_up size_t  nbytes  )  [protected, virtual]
 

Implement the algorithm for rounding up the request to an appropriate chunksize.

Definition at line 116 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE, and ACE::round_to_pagesize().

Referenced by acquire().

00117 {
00118   ACE_TRACE ("ACE_Sbrk_Memory_Pool::round_up");
00119   return ACE::round_to_pagesize (nbytes);
00120 }

int ACE_Sbrk_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 addr.

Definition at line 53 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE.

00054 {
00055   ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
00056   return 0;
00057 }

int ACE_Sbrk_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 46 of file Sbrk_Memory_Pool.cpp.

References ACE_TRACE, and ssize_t.

00047 {
00048   ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
00049   return 0;
00050 }


Member Data Documentation

ACE_Sbrk_Memory_Pool::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 105 of file Sbrk_Memory_Pool.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:28:25 2006 for ACE by doxygen 1.3.6