Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / ACE / ace / SV_Shared_Memory.h
blobccdc71116522aa80056e7f11d850d2cb158b46dc
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file SV_Shared_Memory.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //==========================================================================
11 #ifndef ACE_SV_SHARED_MEMORY_H
12 #define ACE_SV_SHARED_MEMORY_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/ACE_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/os_include/sys/os_stat.h"
23 #include "ace/os_include/sys/os_ipc.h"
24 #include "ace/Default_Constants.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 /**
29 * @class ACE_SV_Shared_Memory
31 * @brief This is a wrapper for System V shared memory.
33 class ACE_Export ACE_SV_Shared_Memory
35 public:
36 enum
38 ACE_CREATE = IPC_CREAT,
39 ACE_OPEN = 0
42 ACE_SV_Shared_Memory ();
43 ACE_SV_Shared_Memory (key_t external_id,
44 size_t size,
45 int create,
46 int perms = ACE_DEFAULT_FILE_PERMS,
47 void *virtual_addr = 0,
48 int flags = 0);
50 ACE_SV_Shared_Memory (ACE_HANDLE internal_id,
51 int flags = 0);
53 int open (key_t external_id,
54 size_t size,
55 int create = ACE_SV_Shared_Memory::ACE_OPEN,
56 int perms = ACE_DEFAULT_FILE_PERMS);
58 int open_and_attach (key_t external_id,
59 size_t size,
60 int create = ACE_SV_Shared_Memory::ACE_OPEN,
61 int perms = ACE_DEFAULT_FILE_PERMS,
62 void *virtual_addr = 0,
63 int flags = 0);
65 /// Attach this shared memory segment.
66 int attach (void *virtual_addr = 0, int flags = 0);
68 /// Detach this shared memory segment.
69 int detach ();
71 /// Remove this shared memory segment.
72 int remove ();
74 /// Forward to underlying System V <shmctl>.
75 int control (int cmd, void *buf);
77 // = Segment-related info.
78 void *get_segment_ptr () const;
79 size_t get_segment_size () const;
81 /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
82 ACE_HANDLE get_id () const;
84 /// Dump the state of an object.
85 void dump () const;
87 /// Declare the dynamic allocation hooks.
88 ACE_ALLOC_HOOK_DECLARE;
90 protected:
91 enum
93 /// Most restrictive alignment.
94 ALIGN_WORDB = 8
97 /// Internal identifier.
98 ACE_HANDLE internal_id_;
100 /// Size of the mapped segment.
101 size_t size_;
103 /// Pointer to the beginning of the segment.
104 void *segment_ptr_;
106 /// Round up to an appropriate page size.
107 size_t round_up (size_t len);
110 ACE_END_VERSIONED_NAMESPACE_DECL
112 #if defined (__ACE_INLINE__)
113 #include "ace/SV_Shared_Memory.inl"
114 #endif /* __ACE_INLINE__ */
116 #include /**/ "ace/post.h"
118 #endif /* ACE_SV_SHARED_MEMORY_H */