This is a wrapper for System V shared memory. More...
#include <SV_Shared_Memory.h>
Public Types | |
| enum | { ACE_CREATE = IPC_CREAT, ACE_OPEN = 0 } |
Public Member Functions | |
| ACE_SV_Shared_Memory (void) | |
| ACE_SV_Shared_Memory (key_t external_id, size_t size, int create, int perms=ACE_DEFAULT_FILE_PERMS, void *virtual_addr=0, int flags=0) | |
| ACE_SV_Shared_Memory (ACE_HANDLE internal_id, int flags=0) | |
| int | open (key_t external_id, size_t size, int create=ACE_SV_Shared_Memory::ACE_OPEN, int perms=ACE_DEFAULT_FILE_PERMS) |
| int | open_and_attach (key_t external_id, size_t size, int create=ACE_SV_Shared_Memory::ACE_OPEN, int perms=ACE_DEFAULT_FILE_PERMS, void *virtual_addr=0, int flags=0) |
| int | attach (void *virtual_addr=0, int flags=0) |
| Attach this shared memory segment. | |
| int | detach (void) |
| Detach this shared memory segment. | |
| int | remove (void) |
| Remove this shared memory segment. | |
| int | control (int cmd, void *buf) |
| Forward to underlying System V <shmctl>. | |
| void * | get_segment_ptr (void) const |
| size_t | get_segment_size (void) const |
| ACE_HANDLE | get_id (void) const |
| Return the ID of the shared memory segment (i.e., an ACE_HANDLE). | |
| void | dump (void) const |
| Dump the state of an object. | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Protected Types | |
| enum | { ALIGN_WORDB = 8 } |
Protected Member Functions | |
| size_t | round_up (size_t len) |
| Round up to an appropriate page size. | |
Protected Attributes | |
| ACE_HANDLE | internal_id_ |
| Internal identifier. | |
| size_t | size_ |
| Size of the mapped segment. | |
| void * | segment_ptr_ |
| Pointer to the beginning of the segment. | |
This is a wrapper for System V shared memory.
Definition at line 35 of file SV_Shared_Memory.h.
| anonymous enum |
Definition at line 38 of file SV_Shared_Memory.h.
{
ACE_CREATE = IPC_CREAT,
ACE_OPEN = 0
};
anonymous enum [protected] |
Definition at line 94 of file SV_Shared_Memory.h.
{
/// Most restrictive alignment.
ALIGN_WORDB = 8
};
| ACE_SV_Shared_Memory::ACE_SV_Shared_Memory | ( | void | ) |
Definition at line 62 of file SV_Shared_Memory.cpp.
: internal_id_ (0), size_ (0), segment_ptr_ (0) { ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory"); }
| ACE_SV_Shared_Memory::ACE_SV_Shared_Memory | ( | key_t | external_id, | |
| size_t | size, | |||
| int | create, | |||
| int | perms = ACE_DEFAULT_FILE_PERMS, |
|||
| void * | virtual_addr = 0, |
|||
| int | flags = 0 | |||
| ) |
Definition at line 46 of file SV_Shared_Memory.cpp.
| ACE_SV_Shared_Memory::ACE_SV_Shared_Memory | ( | ACE_HANDLE | internal_id, | |
| int | flags = 0 | |||
| ) |
Definition at line 77 of file SV_Shared_Memory.cpp.
| int ACE_SV_Shared_Memory::attach | ( | void * | virtual_addr = 0, |
|
| int | flags = 0 | |||
| ) |
Attach this shared memory segment.
Definition at line 44 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::attach");
#if defined (ACE_WIN32)
ACE_UNUSED_ARG(flags);
ACE_UNUSED_ARG(virtual_addr);
ACE_NOTSUP_RETURN (-1);
#else
this->segment_ptr_ = ACE_OS::shmat (this->internal_id_, virtual_addr, flags);
return this->segment_ptr_ == (void *) -1 ? -1 : 0;
#endif /* ACE_WIN32 */
}
| int ACE_SV_Shared_Memory::control | ( | int | cmd, | |
| void * | buf | |||
| ) |
Forward to underlying System V <shmctl>.
Definition at line 60 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::control");
#if defined (ACE_WIN32)
ACE_UNUSED_ARG(cmd);
ACE_UNUSED_ARG(buf);
ACE_NOTSUP_RETURN (-1);
#else
return ACE_OS::shmctl (this->internal_id_, cmd, (struct shmid_ds *) buf);
#endif /* ACE_WIN32 */
}
| int ACE_SV_Shared_Memory::detach | ( | void | ) |
Detach this shared memory segment.
Definition at line 98 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::detach");
return ACE_OS::shmdt (this->segment_ptr_);
}
| void ACE_SV_Shared_Memory::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 17 of file SV_Shared_Memory.cpp.
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_SV_Shared_Memory::dump");
#endif /* ACE_HAS_DUMP */
}
| ACE_HANDLE ACE_SV_Shared_Memory::get_id | ( | void | ) | const |
Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
Definition at line 112 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::get_id");
return this->internal_id_;
}
| void * ACE_SV_Shared_Memory::get_segment_ptr | ( | void | ) | const |
Definition at line 105 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::get_segment_ptr");
return this->segment_ptr_;
}
| size_t ACE_SV_Shared_Memory::get_segment_size | ( | void | ) | const |
Definition at line 75 of file SV_Shared_Memory.inl.
| int ACE_SV_Shared_Memory::open | ( | key_t | external_id, | |
| size_t | size, | |||
| int | create = ACE_SV_Shared_Memory::ACE_OPEN, |
|||
| int | perms = ACE_DEFAULT_FILE_PERMS | |||
| ) |
Definition at line 22 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::open");
#if defined (ACE_WIN32)
ACE_UNUSED_ARG(perms);
ACE_UNUSED_ARG(create);
ACE_UNUSED_ARG(sz);
ACE_UNUSED_ARG(external_id);
ACE_NOTSUP_RETURN (-1);
#else
this->segment_ptr_ = 0;
this->size_ = sz;
this->internal_id_ = ACE_OS::shmget (external_id, sz, create | perms);
return this->internal_id_ == -1 ? -1 : 0;
#endif /* ACE_WIN32 */
}
| int ACE_SV_Shared_Memory::open_and_attach | ( | key_t | external_id, | |
| size_t | size, | |||
| int | create = ACE_SV_Shared_Memory::ACE_OPEN, |
|||
| int | perms = ACE_DEFAULT_FILE_PERMS, |
|||
| void * | virtual_addr = 0, |
|||
| int | flags = 0 | |||
| ) |
Definition at line 28 of file SV_Shared_Memory.cpp.
| int ACE_SV_Shared_Memory::remove | ( | void | ) |
Remove this shared memory segment.
Definition at line 84 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::remove");
#if defined (ACE_WIN32)
ACE_NOTSUP_RETURN (-1);
#else
return ACE_OS::shmctl (this->internal_id_, IPC_RMID, 0);
#endif /* ACE_WIN32 */
}
| size_t ACE_SV_Shared_Memory::round_up | ( | size_t | len | ) | [protected] |
Round up to an appropriate page size.
Definition at line 12 of file SV_Shared_Memory.inl.
{
ACE_TRACE ("ACE_SV_Shared_Memory::round_up");
return (len + ACE_SV_Shared_Memory::ALIGN_WORDB - 1) & ~(ACE_SV_Shared_Memory::ALIGN_WORDB - 1);
}
Declare the dynamic allocation hooks.
Definition at line 91 of file SV_Shared_Memory.h.
ACE_HANDLE ACE_SV_Shared_Memory::internal_id_ [protected] |
Internal identifier.
Definition at line 101 of file SV_Shared_Memory.h.
void* ACE_SV_Shared_Memory::segment_ptr_ [protected] |
Pointer to the beginning of the segment.
Definition at line 107 of file SV_Shared_Memory.h.
size_t ACE_SV_Shared_Memory::size_ [protected] |
Size of the mapped segment.
Definition at line 104 of file SV_Shared_Memory.h.
1.7.0