3 //=============================================================================
5 * @file Sbrk_Memory_Pool.h
7 * @author Dougls C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Prashant Jain <pjain@cs.wustl.edu>
10 //=============================================================================
12 #ifndef ACE_SBRK_MEMORY_POOL_H
13 #define ACE_SBRK_MEMORY_POOL_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #if !defined (ACE_LACKS_SBRK)
26 #include "ace/os_include/sys/os_mman.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 * @class ACE_Sbrk_Memory_Pool_Options
34 * @brief Helper class for Sbrk Memory Pool constructor options.
36 * This should be a nested class, but that breaks too many
39 class ACE_Export ACE_Sbrk_Memory_Pool_Options
44 * @class ACE_Sbrk_Memory_Pool
46 * @brief Make a memory pool that is based on <sbrk(2)>.
48 class ACE_Export ACE_Sbrk_Memory_Pool
51 typedef ACE_Sbrk_Memory_Pool_Options OPTIONS
;
53 /// Initialize the pool.
54 ACE_Sbrk_Memory_Pool (const ACE_TCHAR
*backing_store_name
= 0,
55 const OPTIONS
*options
= 0);
57 virtual ~ACE_Sbrk_Memory_Pool ();
59 // = Implementor operations.
60 /// Ask system for initial chunk of local memory.
61 virtual void *init_acquire (size_t nbytes
,
62 size_t &rounded_bytes
,
65 /// Acquire at least @a nbytes from the memory pool. @a rounded_bytes is
66 /// the actual number of bytes allocated.
67 virtual void *acquire (size_t nbytes
,
68 size_t &rounded_bytes
);
70 /// Instruct the memory pool to release all of its resources.
71 virtual int release (int destroy
= 1);
74 * Sync @a len bytes of the memory region to the backing store
75 * starting at @c this->base_addr_. If @a len == -1 then sync the
78 virtual int sync (ssize_t len
= -1, int flags
= MS_SYNC
);
80 /// Sync @a len bytes of the memory region to the backing store
81 /// starting at @a addr.
82 virtual int sync (void *addr
, size_t len
, int flags
= MS_SYNC
);
85 * Change the protection of the pages of the mapped region to @a prot
86 * starting at @c this->base_addr_ up to @a len bytes. If @a len == -1
87 * then change protection of all pages in the mapped region.
89 virtual int protect (ssize_t len
= -1, int prot
= PROT_RDWR
);
91 /// Change the protection of the pages of the mapped region to @a prot
92 /// starting at @a addr up to @a len bytes.
93 virtual int protect (void *addr
, size_t len
, int prot
= PROT_RDWR
);
95 /// Dump the state of an object.
96 virtual void dump () const;
98 /// Return the base address of this memory pool, 0 if base_addr
100 virtual void *base_addr () const;
102 /// Declare the dynamic allocation hooks.
103 ACE_ALLOC_HOOK_DECLARE
;
106 /// Implement the algorithm for rounding up the request to an
107 /// appropriate chunksize.
108 virtual size_t round_up (size_t nbytes
);
111 ACE_END_VERSIONED_NAMESPACE_DECL
113 #endif /* !ACE_LACKS_SBRK */
115 #include /**/ "ace/post.h"
116 #endif /* ACE_SBRK_MEMORY_POOL_H */