Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# ACE_Shared_Memory_Pool Class Reference

Make a memory pool that is based on System V shared memory (shmget(2) etc.). This implementation allows memory to be shared between processes. If your platform doesn't support System V shared memory (e.g., Win32 and many RTOS platforms do not) then you should use ACE_MMAP_Memory_Pool instead of this class. In fact, you should probably use ACE_MMAP_Memory_Pool on platforms that *do* support System V shared memory since it provides more powerful features, such as persistent backing store and greatly scalability. More...

`#include <Shared_Memory_Pool.h>`

Inheritance diagram for ACE_Shared_Memory_Pool:

[legend]
Collaboration diagram for ACE_Shared_Memory_Pool:

[legend]
List of all members.

## Public Types
typedef ACE_Shared_Memory_Pool_Options | OPTIONS
## Public Member Functions
| ACE_Shared_Memory_Pool (const ACE_TCHAR *backing_store_name=0, const OPTIONS *options=0)
| Initialize the pool.
virtual | ~ACE_Shared_Memory_Pool (void)
virtual void * | init_acquire (size_t nbytes, size_t &rounded_bytes, int &first_time)
| Ask system for initial chunk of local memory.
virtual void * | acquire (size_t nbytes, size_t &rounded_bytes)
virtual int | release (int destroy=1)
| Instruct the memory pool to release all of its resources.
virtual int | sync (ssize_t len=-1, int flags=MS_SYNC)
virtual int | sync (void *addr, size_t len, int flags=MS_SYNC)
| Sync the memory region to the backing store starting at addr.
virtual int | protect (ssize_t len=-1, int prot=PROT_RDWR)
virtual int | protect (void *addr, size_t len, int prot=PROT_RDWR)
virtual void * | base_addr (void) const
virtual void | dump (void) const
| Dump the state of an object.
## Public Attributes
| ACE_ALLOC_HOOK_DECLARE
| Declare the dynamic allocation hooks.
## Protected Member Functions
virtual size_t | round_up (size_t nbytes)
virtual int | commit_backing_store_name (size_t rounded_bytes, off_t &offset)
virtual int | find_seg (const void *const searchPtr, off_t &offset, size_t &counter)
| Find the segment that contains the searchPtr.
virtual int | in_use (off_t &offset, size_t &counter)
| Determine how much memory is currently in use.
virtual int | handle_signal (int signum, siginfo_t *, ucontext_t *)
## Protected Attributes
void * | base_addr_
size_t | file_perms_
| File permissions to use when creating/opening a segment.
size_t | max_segments_
| Number of shared memory segments in the <shm_table> table.
off_t | minimum_bytes_
| What the minimim bytes of the initial segment should be.
size_t | segment_size_
| Shared memory segment size.
key_t | base_shm_key_
| Base shared memory key for the segment.
ACE_Sig_Handler | signal_handler_
| Handles SIGSEGV.

## Detailed Description

Make a memory pool that is based on System V shared memory (shmget(2) etc.). This implementation allows memory to be shared between processes. If your platform doesn't support System V shared memory (e.g., Win32 and many RTOS platforms do not) then you should use ACE_MMAP_Memory_Pool instead of this class. In fact, you should probably use ACE_MMAP_Memory_Pool on platforms that *do* support System V shared memory since it provides more powerful features, such as persistent backing store and greatly scalability.

## Member Typedef Documentation

typedef ACE_Shared_Memory_Pool_Options ACE_Shared_Memory_Pool::OPTIONS

## Constructor & Destructor Documentation

ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool | ( | const ACE_TCHAR * | backing_store_name = `0`,
|  | const OPTIONS * | options = `0`
| ) |

| Initialize the pool.

ACE_Shared_Memory_Pool::~ACE_Shared_Memory_Pool | ( | void |  | ) | `[virtual]`

## Member Function Documentation

void * ACE_Shared_Memory_Pool::acquire | ( | size_t | nbytes,
|  | size_t & | rounded_bytes
| ) | `[virtual]`

| Acquire at least nbytes from the memory pool. rounded_byes is the actual number of bytes allocated. Also acquires an internal semaphore that ensures proper serialization of Memory_Pool initialization across processes.

void * ACE_Shared_Memory_Pool::base_addr | ( | void |  | ) | const`[virtual]`

| Return the base address of this memory pool, 0 if base_addr never changes.

int ACE_Shared_Memory_Pool::commit_backing_store_name | ( | size_t | rounded_bytes,
|  | off_t & | offset
| ) | `[protected, virtual]`

| Commits a new shared memory segment if necessary after an <acquire> or a signal. <offset> is set to the new offset into the backing store.

void ACE_Shared_Memory_Pool::dump | ( | void |  | ) | const`[virtual]`

| Dump the state of an object.

int ACE_Shared_Memory_Pool::find_seg | ( | const void *const | searchPtr,
|  | off_t & | offset,
|  | size_t & | counter
| ) | `[protected, virtual]`

| Find the segment that contains the searchPtr.

int ACE_Shared_Memory_Pool::handle_signal | ( | int | signum,
|  | siginfo_t * | ,
|  | ucontext_t * |
| ) | `[protected, virtual]`

| Handle SIGSEGV and SIGBUS signals to remap shared memory properly. Reimplemented from ACE_Event_Handler.

int ACE_Shared_Memory_Pool::in_use | ( | off_t & | offset,
|  | size_t & | counter
| ) | `[protected, virtual]`

| Determine how much memory is currently in use.

void * ACE_Shared_Memory_Pool::init_acquire | ( | size_t | nbytes,
|  | size_t & | rounded_bytes,
|  | int & | first_time
| ) | `[virtual]`

| Ask system for initial chunk of local memory.

int ACE_Shared_Memory_Pool::protect | ( | void * | addr,
|  | size_t | len,
|  | int | prot = `PROT_RDWR`
| ) | `[virtual]`

| Change the protection of the pages of the mapped region to <prot> starting at <addr> up to <len> bytes.

int ACE_Shared_Memory_Pool::protect | ( | ssize_t | len = `-1`,
|  | int | prot = `PROT_RDWR`
| ) | `[virtual]`

| Change the protection of the pages of the mapped region to <prot> starting at `this->base_addr_` up to len bytes. If len == -1 then change protection of all pages in the mapped region.

int ACE_Shared_Memory_Pool::release | ( | int | destroy = `1` | ) | `[virtual]`

| Instruct the memory pool to release all of its resources.

size_t ACE_Shared_Memory_Pool::round_up | ( | size_t | nbytes | ) | `[protected, virtual]`

| Implement the algorithm for rounding up the request to an appropriate chunksize.

int ACE_Shared_Memory_Pool::sync | ( | void * | addr,
|  | size_t | len,
|  | int | flags = `MS_SYNC`
| ) | `[virtual]`

| Sync the memory region to the backing store starting at addr.

int ACE_Shared_Memory_Pool::sync | ( | ssize_t | len = `-1`,
|  | int | flags = `MS_SYNC`
| ) | `[virtual]`

| Sync the memory region to the backing store starting at `this->base_addr_`.

## Member Data Documentation

ACE_Shared_Memory_Pool::ACE_ALLOC_HOOK_DECLARE

| Declare the dynamic allocation hooks.

void* ACE_Shared_Memory_Pool::base_addr_`[protected]`

| Base address of the shared memory segment. If this has the value of 0 then the OS is free to select any address, otherwise this value is what the OS must try to use to map the shared memory segment.

key_t ACE_Shared_Memory_Pool::base_shm_key_`[protected]`

| Base shared memory key for the segment.

size_t ACE_Shared_Memory_Pool::file_perms_`[protected]`

| File permissions to use when creating/opening a segment.

size_t ACE_Shared_Memory_Pool::max_segments_`[protected]`

| Number of shared memory segments in the <shm_table> table.

off_t ACE_Shared_Memory_Pool::minimum_bytes_`[protected]`

| What the minimim bytes of the initial segment should be.

size_t ACE_Shared_Memory_Pool::segment_size_`[protected]`

| Shared memory segment size.

ACE_Sig_Handler ACE_Shared_Memory_Pool::signal_handler_`[protected]`

| Handles SIGSEGV.

The documentation for this class was generated from the following files:

- Shared_Memory_Pool.h
- Shared_Memory_Pool.cpp