Shared_Memory_MM.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Shared_Memory_MM.h
00006  *
00007  *  Shared_Memory_MM.h,v 4.21 2006/04/08 23:34:53 schmidt Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_SHARED_MALLOC_MM_H
00015 #define ACE_SHARED_MALLOC_MM_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/Shared_Memory.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/Mem_Map.h"
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 /**
00029  * @class ACE_Shared_Memory_MM
00030  *
00031  * @brief Shared memory wrapper based on MMAP.
00032  *
00033  * This class provides a very simple-minded shared memory manager.  We
00034  * strongly recommend that you do NOT use this class.  Instead, please
00035  * use @c ACE_Malloc, which has much more powerful capabilities.
00036  */
00037 class ACE_Export ACE_Shared_Memory_MM : public ACE_Shared_Memory
00038 {
00039 public:
00040   // = Initialization and termination methods.
00041   /// Default constructor.
00042   ACE_Shared_Memory_MM (void);
00043 
00044   /// Constructor.
00045   ACE_Shared_Memory_MM (ACE_HANDLE handle,
00046                         int length = -1,
00047                         int prot = PROT_RDWR,
00048                         int share = ACE_MAP_PRIVATE,
00049                         char *addr = 0,
00050                         off_t pos = 0);
00051 
00052   /// Constructor.
00053   ACE_Shared_Memory_MM (const ACE_TCHAR *file_name,
00054                         int len = -1,
00055                         int flags = O_RDWR | O_CREAT,
00056                         int mode = ACE_DEFAULT_FILE_PERMS,
00057                         int prot = PROT_RDWR,
00058                         int share = ACE_MAP_SHARED,
00059                         char *addr = 0, off_t pos = 0);
00060 
00061   /// Open method.
00062   int open (ACE_HANDLE handle,
00063             int length = -1,
00064             int prot = PROT_RDWR,
00065             int share = ACE_MAP_PRIVATE,
00066             char *addr = 0,
00067             off_t pos = 0);
00068 
00069   /// Open method.
00070   int open (const ACE_TCHAR *file_name,
00071             int len = -1,
00072             int flags = O_RDWR | O_CREAT,
00073             int mode = ACE_DEFAULT_FILE_PERMS,
00074             int prot = PROT_RDWR,
00075             int share = ACE_MAP_SHARED,
00076             char *addr = 0,
00077             off_t pos = 0);
00078 
00079   /// Return the name of file that is mapped (if any).
00080   const ACE_TCHAR *filename (void) const;
00081 
00082   /// Close down the shared memory segment.
00083   virtual int close (void);
00084 
00085   /// Remove the shared memory segment and the underlying file.
00086   virtual int remove (void);
00087 
00088   // = Allocation and deallocation methods.
00089   /// Create a new chuck of memory containing <size> bytes.
00090   virtual void *malloc (size_t size = 0);
00091 
00092   /// Free a chuck of memory allocated by
00093   /// <ACE_Shared_Memory_MM::malloc>.
00094   virtual int free (void *p);
00095 
00096   /// Return the size of the shared memory segment.
00097   virtual int get_segment_size (void) const;
00098 
00099   /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
00100   virtual ACE_HANDLE get_id (void) const;
00101 
00102   /// Dump the state of an object.
00103   void dump (void) const;
00104 
00105   /// Declare the dynamic allocation hooks.
00106   ACE_ALLOC_HOOK_DECLARE;
00107 
00108 private:
00109    /// This version is implemented with memory-mapped files.
00110    ACE_Mem_Map shared_memory_;
00111 };
00112 
00113 ACE_END_VERSIONED_NAMESPACE_DECL
00114 
00115 #if defined (__ACE_INLINE__)
00116 #include "ace/Shared_Memory_MM.inl"
00117 #endif /* __ACE_INLINE__ */
00118 
00119 #include /**/ "ace/post.h"
00120 #endif /* ACE_SHARED_MALLOC_MM_H */

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