Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / ace / Shared_Memory_MM.h
blob1fdbf3afb7759475f763953bd8afdeb680f5aa67
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Shared_Memory_MM.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_SHARED_MALLOC_MM_H
12 #define ACE_SHARED_MALLOC_MM_H
13 #include /**/ "ace/pre.h"
15 #include "ace/Shared_Memory.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Mem_Map.h"
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
25 /**
26 * @class ACE_Shared_Memory_MM
28 * @brief Shared memory wrapper based on MMAP.
30 * This class provides a very simple-minded shared memory manager. We
31 * strongly recommend that you do NOT use this class. Instead, please
32 * use @c ACE_Malloc, which has much more powerful capabilities.
34 class ACE_Export ACE_Shared_Memory_MM : public ACE_Shared_Memory
36 public:
37 /// Default constructor.
38 ACE_Shared_Memory_MM ();
40 /// Constructor.
41 ACE_Shared_Memory_MM (ACE_HANDLE handle,
42 size_t length = static_cast<size_t> (-1),
43 int prot = PROT_RDWR,
44 int share = ACE_MAP_PRIVATE,
45 char *addr = 0,
46 ACE_OFF_T pos = 0);
48 /// Constructor.
49 ACE_Shared_Memory_MM (const ACE_TCHAR *file_name,
50 size_t length = static_cast<size_t> (-1),
51 int flags = O_RDWR | O_CREAT,
52 int mode = ACE_DEFAULT_FILE_PERMS,
53 int prot = PROT_RDWR,
54 int share = ACE_MAP_SHARED,
55 char *addr = 0, ACE_OFF_T pos = 0);
57 /// Open method.
58 int open (ACE_HANDLE handle,
59 size_t length = static_cast<size_t> (-1),
60 int prot = PROT_RDWR,
61 int share = ACE_MAP_PRIVATE,
62 char *addr = 0,
63 ACE_OFF_T pos = 0);
65 /// Open method.
66 int open (const ACE_TCHAR *file_name,
67 size_t length = static_cast<size_t> (-1),
68 int flags = O_RDWR | O_CREAT,
69 int mode = ACE_DEFAULT_FILE_PERMS,
70 int prot = PROT_RDWR,
71 int share = ACE_MAP_SHARED,
72 char *addr = 0,
73 ACE_OFF_T pos = 0);
75 /// Return the name of file that is mapped (if any).
76 const ACE_TCHAR *filename () const;
78 /// Close down the shared memory segment.
79 virtual int close ();
81 /// Remove the shared memory segment and the underlying file.
82 virtual int remove ();
84 // = Allocation and deallocation methods.
85 /// Create a new chuck of memory containing @a size bytes.
86 virtual void *malloc (size_t size = 0);
88 /// Free a chuck of memory allocated by
89 /// ACE_Shared_Memory_MM::malloc.
90 virtual int free (void *p);
92 /// Return the size of the shared memory segment.
93 virtual size_t get_segment_size () const;
95 /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
96 virtual ACE_HANDLE get_id () const;
98 /// Dump the state of an object.
99 void dump () const;
101 /// Declare the dynamic allocation hooks.
102 ACE_ALLOC_HOOK_DECLARE;
104 private:
105 /// This version is implemented with memory-mapped files.
106 ACE_Mem_Map shared_memory_;
109 ACE_END_VERSIONED_NAMESPACE_DECL
111 #if defined (__ACE_INLINE__)
112 #include "ace/Shared_Memory_MM.inl"
113 #endif /* __ACE_INLINE__ */
115 #include /**/ "ace/post.h"
116 #endif /* ACE_SHARED_MALLOC_MM_H */