Document return values
[ACE_TAO.git] / ACE / ace / Local_Memory_Pool.h
blob0df0631a9be8b1b402246930a5258882b9243b93
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Local_Memory_Pool.h
7 * @author Dougls C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Prashant Jain <pjain@cs.wustl.edu>
9 */
10 //=============================================================================
12 #ifndef ACE_LOCAL_MEMORY_POOL_H
13 #define ACE_LOCAL_MEMORY_POOL_H
14 #include /**/ "ace/pre.h"
16 #include "ace/os_include/sys/os_mman.h" /* Need PROT_RDWR */
17 #include "ace/ACE.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Unbounded_Set.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class ACE_Local_Memory_Pool_Options
30 * @brief Helper class for Local Memory Pool constructor options.
32 * This should be a nested class, but that breaks too many
33 * compilers.
35 class ACE_Export ACE_Local_Memory_Pool_Options
39 /**
40 * @class ACE_Local_Memory_Pool
42 * @brief Make a memory pool that is based on C++ new/delete. This is
43 * useful for integrating existing components that use new/delete
44 * into the ACE Malloc scheme...
46 class ACE_Export ACE_Local_Memory_Pool
48 public:
49 typedef ACE_Local_Memory_Pool_Options OPTIONS;
51 /// Initialize the pool.
52 ACE_Local_Memory_Pool (const ACE_TCHAR *backing_store_name = 0,
53 const OPTIONS *options = 0);
55 virtual ~ACE_Local_Memory_Pool ();
57 /// Ask system for initial chunk of local memory.
58 virtual void *init_acquire (size_t nbytes,
59 size_t &rounded_bytes,
60 int &first_time);
62 /// Acquire at least @a nbytes from the memory pool. @a rounded_bytes is
63 /// the actual number of bytes allocated.
64 virtual void *acquire (size_t nbytes,
65 size_t &rounded_bytes);
67 /// Instruct the memory pool to release all of its resources.
68 virtual int release (int destroy = 1);
70 /**
71 * Sync @a len bytes of the memory region to the backing store
72 * starting at <this->base_addr_>. If @a len == -1 then sync the
73 * whole region.
75 virtual int sync (ssize_t len = -1, int flags = MS_SYNC);
77 /// Sync @a len bytes of the memory region to the backing store
78 /// starting at @a add_.
79 virtual int sync (void *addr, size_t len, int flags = MS_SYNC);
81 /**
82 * Change the protection of the pages of the mapped region to @a prot
83 * starting at <this->base_addr_> up to @a len bytes. If @a len == -1
84 * then change protection of all pages in the mapped region.
86 virtual int protect (ssize_t len = -1, int prot = PROT_RDWR);
88 /// Change the protection of the pages of the mapped region to @a prot
89 /// starting at @a addr up to @a len bytes.
90 virtual int protect (void *addr, size_t len, int prot = PROT_RDWR);
92 #if defined (ACE_WIN32)
93 /**
94 * Win32 Structural exception selector. The return value decides
95 * how to handle memory pool related structural exceptions. Returns
96 * 1, 0, or , -1.
98 virtual int seh_selector (void *);
99 #endif /* ACE_WIN32 */
102 * Try to extend the virtual address space so that @a addr is now
103 * covered by the address mapping. Always returns 0 since we can't
104 * remap a local memory pool.
106 virtual int remap (void *addr);
108 /// Return the base address of this memory pool, 0 if base_addr
109 /// never changes.
110 virtual void *base_addr () const;
112 /// Dump the state of an object.
113 virtual void dump () const;
115 /// Declare the dynamic allocation hooks.
116 ACE_ALLOC_HOOK_DECLARE;
118 protected:
119 /// List of memory that we have allocated.
120 ACE_Unbounded_Set<char *> allocated_chunks_;
122 /// Implement the algorithm for rounding up the request to an
123 /// appropriate chunksize.
124 virtual size_t round_up (size_t nbytes);
127 ACE_END_VERSIONED_NAMESPACE_DECL
129 #include /**/ "ace/post.h"
130 #endif /* ACE_LOCAL_MEMORY_POOL_H */