Sbrk_Memory_Pool.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file     Sbrk_Memory_Pool.h
00006  *
00007  *  Sbrk_Memory_Pool.h,v 4.6 2005/11/26 03:13:13 ossama Exp
00008  *
00009  *  @author Dougls C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Prashant Jain <pjain@cs.wustl.edu>
00011  */
00012 //=============================================================================
00013 
00014 #ifndef ACE_SBRK_MEMORY_POOL_H
00015 #define ACE_SBRK_MEMORY_POOL_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "ace/ACE_export.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #if !defined (ACE_LACKS_SBRK)
00026 
00027 #include "ace/ACE.h"
00028 #include "ace/os_include/sys/os_mman.h"
00029 
00030 
00031 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 /**
00034  * @class ACE_Sbrk_Memory_Pool_Options
00035  *
00036  * @brief Helper class for Sbrk Memory Pool constructor options.
00037  *
00038  * This should be a nested class, but that breaks too many
00039  * compilers.
00040  */
00041 class ACE_Export ACE_Sbrk_Memory_Pool_Options
00042 {
00043 };
00044 
00045 /**
00046  * @class ACE_Sbrk_Memory_Pool
00047  *
00048  * @brief Make a memory pool that is based on <sbrk(2)>.
00049  */
00050 class ACE_Export ACE_Sbrk_Memory_Pool
00051 {
00052 public:
00053   typedef ACE_Sbrk_Memory_Pool_Options OPTIONS;
00054 
00055   /// Initialize the pool.
00056   ACE_Sbrk_Memory_Pool (const ACE_TCHAR *backing_store_name = 0,
00057                         const OPTIONS *options = 0);
00058 
00059   virtual ~ACE_Sbrk_Memory_Pool (void);
00060 
00061   // = Implementor operations.
00062   /// Ask system for initial chunk of local memory.
00063   virtual void *init_acquire (size_t nbytes,
00064                               size_t &rounded_bytes,
00065                               int &first_time);
00066 
00067   /// Acquire at least @a nbytes from the memory pool. @a rounded_bytes is
00068   /// the actual number of bytes allocated.
00069   virtual void *acquire (size_t nbytes,
00070                          size_t &rounded_bytes);
00071 
00072   /// Instruct the memory pool to release all of its resources.
00073   virtual int release (int destroy = 1);
00074 
00075   /**
00076    * Sync @a len bytes of the memory region to the backing store
00077    * starting at @c this->base_addr_.  If @a len == -1 then sync the
00078    * whole region.
00079    */
00080   virtual int sync (ssize_t len = -1, int flags = MS_SYNC);
00081 
00082   /// Sync @a len bytes of the memory region to the backing store
00083   /// starting at @a addr.
00084   virtual int sync (void *addr, size_t len, int flags = MS_SYNC);
00085 
00086   /**
00087    * Change the protection of the pages of the mapped region to <prot>
00088    * starting at @c this->base_addr_ up to @a len bytes.  If @a len == -1
00089    * then change protection of all pages in the mapped region.
00090    */
00091   virtual int protect (ssize_t len = -1, int prot = PROT_RDWR);
00092 
00093   /// Change the protection of the pages of the mapped region to @a prot
00094   /// starting at @a addr up to @a len bytes.
00095   virtual int protect (void *addr, size_t len, int prot = PROT_RDWR);
00096 
00097   /// Dump the state of an object.
00098   virtual void dump (void) const;
00099 
00100   /// Return the base address of this memory pool, 0 if base_addr
00101   /// never changes.
00102   virtual void *base_addr (void) const;
00103 
00104   /// Declare the dynamic allocation hooks.
00105   ACE_ALLOC_HOOK_DECLARE;
00106 
00107 protected:
00108   /// Implement the algorithm for rounding up the request to an
00109   /// appropriate chunksize.
00110   virtual size_t round_up (size_t nbytes);
00111 };
00112 
00113 ACE_END_VERSIONED_NAMESPACE_DECL
00114 
00115 #endif /* !ACE_LACKS_SBRK */
00116 
00117 #include /**/ "ace/post.h"
00118 #endif /* ACE_SBRK_MEMORY_POOL_H */

Generated on Thu Nov 9 09:42:02 2006 for ACE by doxygen 1.3.6