Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Sbrk_Memory_Pool Class Reference

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

#include <Memory_Pool.h>

List of all members.

Public Types

typedef ACE_Sbrk_Memory_Pool_Options OPTIONS

Public Methods

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

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. More...

virtual void * acquire (size_t nbytes, size_t &rounded_bytes)
 Acquire at least NBYTES from the memory pool. ROUNDED_BYTES is the actual number of bytes allocated. More...

virtual int release (int destroy=1)
 Instruct the memory pool to release all of its resources. More...

virtual int sync (ssize_t len=-1, int flags=MS_SYNC)
virtual int sync (void *addr, size_t len, int flags=MS_SYNC)
 Sync <len> bytes of the memory region to the backing store starting at <addr_>. More...

virtual int protect (ssize_t len=-1, int prot=PROT_RDWR)
virtual int protect (void *addr, size_t len, int prot=PROT_RDWR)
 Change the protection of the pages of the mapped region to <prot> starting at <addr> up to <len> bytes. More...

virtual void dump (void) const
 Dump the state of an object. More...

virtual void * base_addr (void) const
 Return the base address of this memory pool, 0 if base_addr never changes. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

virtual size_t round_up (size_t nbytes)
 Implement the algorithm for rounding up the request to an appropriate chunksize. More...


Detailed Description

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

Definition at line 50 of file Memory_Pool.h.


Member Typedef Documentation

typedef ACE_Sbrk_Memory_Pool_Options ACE_Sbrk_Memory_Pool::OPTIONS
 

Definition at line 53 of file 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 600 of file Memory_Pool.cpp.

References ACE_TCHAR, and ACE_TRACE.

00602 {
00603   ACE_TRACE ("ACE_Sbrk_Memory_Pool::ACE_Sbrk_Memory_Pool");
00604 }

ACE_INLINE ACE_Sbrk_Memory_Pool::~ACE_Sbrk_Memory_Pool void    [virtual]
 

Definition at line 152 of file Memory_Pool.i.

00153 {
00154 }


Member Function Documentation

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 576 of file Memory_Pool.cpp.

References ACE_ERROR_RETURN, ACE_TRACE, LM_ERROR, MAP_FAILED, round_up, and ACE_OS_Memory::sbrk.

Referenced by init_acquire.

00578 {
00579   ACE_TRACE ("ACE_Sbrk_Memory_Pool::acquire");
00580   rounded_bytes = this->round_up (nbytes);
00581   // ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%P|%t) acquiring more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes));
00582   void *cp = ACE_OS::sbrk (rounded_bytes);
00583 
00584   if (cp == MAP_FAILED)
00585     ACE_ERROR_RETURN ((LM_ERROR,
00586                        "(%P|%t) cp = %u\n",
00587                        cp),
00588                       0);
00589   else
00590     // 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));
00591   return cp;
00592 }

ACE_INLINE 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 157 of file Memory_Pool.i.

00158 {
00159   return 0;
00160 }

void ACE_Sbrk_Memory_Pool::dump void    const [virtual]
 

Dump the state of an object.

Definition at line 595 of file Memory_Pool.cpp.

References ACE_TRACE.

00596 {
00597   ACE_TRACE ("ACE_Sbrk_Memory_Pool::dump");
00598 }

ACE_INLINE 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 165 of file Memory_Pool.i.

References ACE_TRACE, and acquire.

00168 {
00169   ACE_TRACE ("ACE_Sbrk_Memory_Pool::init_acquire");
00170   // Note that we assume that when ACE_Sbrk_Memory_Pool is used,
00171   // ACE_Malloc's constructor will only get called once.  If this
00172   // assumption doesn't hold, we are in deep trouble!
00173 
00174   first_time = 1;
00175   return this->acquire (nbytes, rounded_bytes);
00176 }

ACE_INLINE 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 218 of file Memory_Pool.i.

References ACE_TRACE.

00219 {
00220   ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
00221   return 0;
00222 }

ACE_INLINE 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 <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 211 of file Memory_Pool.i.

References ACE_TRACE, and ssize_t.

00212 {
00213   ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
00214   return 0;
00215 }

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

Instruct the memory pool to release all of its resources.

Definition at line 190 of file Memory_Pool.i.

References ACE_TRACE.

00191 {
00192   ACE_TRACE ("ACE_Sbrk_Memory_Pool::release");
00193   return 0;
00194 }

ACE_INLINE 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 181 of file Memory_Pool.i.

References ACE_TRACE, and ACE::round_to_pagesize.

Referenced by acquire.

00182 {
00183   ACE_TRACE ("ACE_Sbrk_Memory_Pool::round_up");
00184   return ACE::round_to_pagesize (nbytes);
00185 }

ACE_INLINE 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 204 of file Memory_Pool.i.

References ACE_TRACE.

00205 {
00206   ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
00207   return 0;
00208 }

ACE_INLINE 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 197 of file Memory_Pool.i.

References ACE_TRACE, and ssize_t.

00198 {
00199   ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
00200   return 0;
00201 }


Member Data Documentation

ACE_Sbrk_Memory_Pool::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 105 of file Memory_Pool.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:55:30 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002