Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Shared_Memory_MM.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Shared_Memory_MM.h
00006  *
00007  *  $Id: Shared_Memory_MM.h,v 1.1.1.3 2001/12/04 14:33:09 chad Exp $
00008  *
00009  *  @author Doug Schmidt
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 /**
00027  * @class ACE_Shared_Memory_MM
00028  *
00029  * @brief Shared memory wrapper based on MMAP.
00030  *
00031  * This class provides a very simple-minded shared memory
00032  * manager.  For more a powerful memory allocator please see
00033  * <ACE_Malloc>.
00034  */
00035 class ACE_Export ACE_Shared_Memory_MM : public ACE_Shared_Memory
00036 {
00037 public:
00038   // = Initialization and termination methods.
00039   /// Default constructor.
00040   ACE_Shared_Memory_MM (void);
00041 
00042   /// Constructor.
00043   ACE_Shared_Memory_MM (ACE_HANDLE handle,
00044                         int length = -1,
00045                         int prot = PROT_RDWR,
00046                         int share = ACE_MAP_PRIVATE,
00047                         char *addr = 0,
00048                         off_t pos = 0);
00049 
00050   /// Constructor.
00051   ACE_Shared_Memory_MM (const ACE_TCHAR *file_name,
00052                         int len = -1,
00053                         int flags = O_RDWR | O_CREAT,
00054                         int mode = ACE_DEFAULT_FILE_PERMS,
00055                         int prot = PROT_RDWR,
00056                         int share = ACE_MAP_SHARED,
00057                         char *addr = 0, off_t pos = 0);
00058 
00059   /// Open method.
00060   int open (ACE_HANDLE handle,
00061             int length = -1,
00062             int prot = PROT_RDWR,
00063             int share = ACE_MAP_PRIVATE,
00064             char *addr = 0,
00065             off_t pos = 0);
00066 
00067   /// Open method.
00068   int open (const ACE_TCHAR *file_name,
00069             int len = -1,
00070             int flags = O_RDWR | O_CREAT,
00071             int mode = ACE_DEFAULT_FILE_PERMS,
00072             int prot = PROT_RDWR,
00073             int share = ACE_MAP_SHARED,
00074             char *addr = 0,
00075             off_t pos = 0);
00076 
00077   /// Return the name of file that is mapped (if any).
00078   const ACE_TCHAR *filename (void) const;
00079 
00080   /// Close down the shared memory segment.
00081   virtual int close (void);
00082 
00083   /// Remove the shared memory segment and the underlying file.
00084   virtual int remove (void);
00085 
00086   // = Allocation and deallocation methods.
00087   /// Create a new chuck of memory containing <size> bytes.
00088   virtual void *malloc (size_t size = 0);
00089 
00090   /// Free a chuck of memory allocated by
00091   /// <ACE_Shared_Memory_MM::malloc>.
00092   virtual int free (void *p);
00093 
00094   /// Return the size of the shared memory segment.
00095   virtual int get_segment_size (void) const;
00096 
00097   /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
00098   virtual ACE_HANDLE get_id (void) const;
00099 
00100   /// Dump the state of an object.
00101   void dump (void) const;
00102 
00103   /// Declare the dynamic allocation hooks.
00104   ACE_ALLOC_HOOK_DECLARE;
00105 
00106 private:
00107    /// This version is implemented with memory-mapped files.
00108    ACE_Mem_Map shared_memory_;
00109 };
00110 
00111 #if defined (__ACE_INLINE__)
00112 #include "ace/Shared_Memory_MM.i"
00113 #endif /* __ACE_INLINE__ */
00114 
00115 #include "ace/post.h"
00116 #endif /* ACE_SHARED_MALLOC_MM_H */

Generated on Mon Jun 16 11:21:13 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002