Public Types | Public Member Functions

base::SynchronizedSharedMemory Class Reference

A class for synchronized operation on a (one) shared memory segment. More...

#include <libppbase/base/SynchronizedSharedMemory.h>

Inheritance diagram for base::SynchronizedSharedMemory:
base::SharedMemory

List of all members.

Public Types

enum  waitE { waitNone = 0, waitEmpty = 1, waitFull = 2 }
 

Specifies the events to signal and wait for in the lock() and unlock() methods.

More...

Public Member Functions

 SynchronizedSharedMemory ()
 Creates an empty object.
 ~SynchronizedSharedMemory ()
 Unmaps the shared memory segment if it is still mapped.
void close ()
 Closes the shared memory segment.
void destroy ()
 Destroys the shared memory segment.
void lock (waitE wait=waitNone)
 Locks the shared memory segment for exclusive access, possibly signalling and waiting for a condition.
void open (const char *name, unsigned size, int flags=0)
 Opens or creates a shared memory segment.
void unlock (waitE wait=waitNone)
 Unlocks the shared memory segment from exclusive access, possibly signalling a condition.

Detailed Description

A class for synchronized operation on a (one) shared memory segment.

Author:
Christoph Schwarz
Version:
$Id: SynchronizedSharedMemory.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Enumeration Documentation

Specifies the events to signal and wait for in the lock() and unlock() methods.

Enumerator:
waitNone 

no signalling/waiting

waitEmpty 

signal full event and/or wait for empty event

waitFull 

signal empty event and/or wait for full event


Member Function Documentation

void base::SynchronizedSharedMemory::destroy (  ) 

Destroys the shared memory segment.

Under Linux you must explicitly destroy a shared memory segment with this method. Windows destroys a shared memory segment when there are no more open handles to it, so this method does nothing.

Reimplemented from base::SharedMemory.

void base::SynchronizedSharedMemory::lock ( waitE  wait = waitNone  ) 

Locks the shared memory segment for exclusive access, possibly signalling and waiting for a condition.

wait specifies the condition to signal and wait for:

  • waitNone does not signal or wait for any condition
  • waitEmpty signals that the segment contains data and waits for it to become empty
  • waitFull signals that the segment is empty and waits for it to contain some data
Parameters:
wait specifies the condition to signal and wait for
void base::SynchronizedSharedMemory::open ( const char *  name,
unsigned  size,
int  flags = 0 
)

Opens or creates a shared memory segment.

Parameters:
name the segment name, must be an integer in string form under Linux
size size of the segment in bytes
flags open flags

Reimplemented from base::SharedMemory.

void base::SynchronizedSharedMemory::unlock ( waitE  wait = waitNone  ) 

Unlocks the shared memory segment from exclusive access, possibly signalling a condition.

wait specifies the condition to signal:

  • waitNone does not signal anything
  • waitEmpty signals that there is some data available
  • waitFull signals that there is no data available, i.e. the segment is empty
Parameters:
wait specifies the condition to signal

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