3 //=============================================================================
5 * @file Sbrk_Memory_Pool.h
7 * $Id: Sbrk_Memory_Pool.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Dougls C. Schmidt <schmidt@cs.wustl.edu>
10 * @author Prashant Jain <pjain@cs.wustl.edu>
12 //=============================================================================
14 #ifndef ACE_SBRK_MEMORY_POOL_H
15 #define ACE_SBRK_MEMORY_POOL_H
17 #include /**/ "ace/pre.h"
19 #include /**/ "ace/ACE_export.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #if !defined (ACE_LACKS_SBRK)
28 #include "ace/os_include/sys/os_mman.h"
31 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
34 * @class ACE_Sbrk_Memory_Pool_Options
36 * @brief Helper class for Sbrk Memory Pool constructor options.
38 * This should be a nested class, but that breaks too many
41 class ACE_Export ACE_Sbrk_Memory_Pool_Options
46 * @class ACE_Sbrk_Memory_Pool
48 * @brief Make a memory pool that is based on <sbrk(2)>.
50 class ACE_Export ACE_Sbrk_Memory_Pool
53 typedef ACE_Sbrk_Memory_Pool_Options OPTIONS
;
55 /// Initialize the pool.
56 ACE_Sbrk_Memory_Pool (const ACE_TCHAR
*backing_store_name
= 0,
57 const OPTIONS
*options
= 0);
59 virtual ~ACE_Sbrk_Memory_Pool (void);
61 // = Implementor operations.
62 /// Ask system for initial chunk of local memory.
63 virtual void *init_acquire (size_t nbytes
,
64 size_t &rounded_bytes
,
67 /// Acquire at least @a nbytes from the memory pool. @a rounded_bytes is
68 /// the actual number of bytes allocated.
69 virtual void *acquire (size_t nbytes
,
70 size_t &rounded_bytes
);
72 /// Instruct the memory pool to release all of its resources.
73 virtual int release (int destroy
= 1);
76 * Sync @a len bytes of the memory region to the backing store
77 * starting at @c this->base_addr_. If @a len == -1 then sync the
80 virtual int sync (ssize_t len
= -1, int flags
= MS_SYNC
);
82 /// Sync @a len bytes of the memory region to the backing store
83 /// starting at @a addr.
84 virtual int sync (void *addr
, size_t len
, int flags
= MS_SYNC
);
87 * Change the protection of the pages of the mapped region to @a prot
88 * starting at @c this->base_addr_ up to @a len bytes. If @a len == -1
89 * then change protection of all pages in the mapped region.
91 virtual int protect (ssize_t len
= -1, int prot
= PROT_RDWR
);
93 /// Change the protection of the pages of the mapped region to @a prot
94 /// starting at @a addr up to @a len bytes.
95 virtual int protect (void *addr
, size_t len
, int prot
= PROT_RDWR
);
97 /// Dump the state of an object.
98 virtual void dump (void) const;
100 /// Return the base address of this memory pool, 0 if base_addr
102 virtual void *base_addr (void) const;
104 /// Declare the dynamic allocation hooks.
105 ACE_ALLOC_HOOK_DECLARE
;
108 /// Implement the algorithm for rounding up the request to an
109 /// appropriate chunksize.
110 virtual size_t round_up (size_t nbytes
);
113 ACE_END_VERSIONED_NAMESPACE_DECL
115 #endif /* !ACE_LACKS_SBRK */
117 #include /**/ "ace/post.h"
118 #endif /* ACE_SBRK_MEMORY_POOL_H */