Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeSharedMemZone Class Reference

an easy to use process-safe shared memory zone More...

#include <cascade/interprocess/CascadeSharedMemZone.h>

Inheritance diagram for CascadeSharedMemZone:

CascadeObject List of all members.

Public Member Functions

 CascadeSharedMemZone ()
virtual ~CascadeSharedMemZone ()
bool Open (const char *pName, u32 nNumBytes, bool bCreateIfNecessary)
bool Close ()
void * MapLock ()
bool Unlock ()
u32 GetSize ()
const char * GetName ()

Detailed Description

an easy to use process-safe shared memory zone

Skip the description

CascadeSharedMemZone provides an easy to use process-safe locking shared memory zone.


class CascadeSharedMemZone


Constructor & Destructor Documentation

CascadeSharedMemZone::CascadeSharedMemZone  ) 
 

the default constructor - lightweight

This default constructor is lightweight.

virtual CascadeSharedMemZone::~CascadeSharedMemZone  )  [virtual]
 

destructor

This destructor will unlock and close the SharedMemZone if necessary.


Member Function Documentation

bool CascadeSharedMemZone::Close  ) 
 

closes the SharedMemZone

Call Close() to close a previously opened shared memory zone. When the last handle to a shared memory zone is closed, the operating system shared memory object is destroyed.

This function is provided for convenience - the destructor ~CascadeSharedMemZone() will automatically Close() the shared memory zone if it is still open when the destructor is called. Close() will automatically unlock the shared memory zone if it is map-locked, but good programming practice dictates that you should unlock the shared memory zone yourself.

Returns:
whether or not the close was successful
See also:
Open()

Unlock(), ~CascadeSharedMemZone()

const char* CascadeSharedMemZone::GetName  ) 
 

gets the name of the SharedMemZone

Gets the name of an open zone or NULL if zone is not open.

Returns:
the name of the SharedMemZone or NULL if the zone is not open
See also:
Open()

GetSize()

u32 CascadeSharedMemZone::GetSize  ) 
 

gets the size of the SharedMemZone

Gets the size of an open zone or 0 if zone is not open.

Returns:
the size of the SharedMemZone
See also:
Open()

GetName()

void* CascadeSharedMemZone::MapLock  ) 
 

locks and maps the SharedMemZone into your process' address space

Call MapLock() to lock the shared memory zone and map it into the client process' address space. MapLock() returns the address of the mapped shared memory on success and NULL on failure. The shared memory zone must be opened with a call to Open() before MapLock() will succeed.

Returns:
a pointer to the shared memory or NULL of the zone could not be MapLocked()
Note:
Do not cache the return value from MapLock() - it may be different each time the shared memory zone is mapped.

Do not store absolute pointers in shared memory zones. Instead use relative pointers.

See also:
Unlock(), Close(), ~CascadeSharedMemZone()

bool CascadeSharedMemZone::Open const char *  pName,
u32  nNumBytes,
bool  bCreateIfNecessary
 

opens a SharedMemzone

Open() opens a handle to the shared memory zone named pName with size nNumBytes creating it if necessary and bCreateIfNecessary is true. Open() returns false on failure or if the named zone already exists in a different size. Otherwise Open() returns true. If Open() creates a new shared mem zone, the first 32 bits of the zone will be initialized to zero, allowing the client to determine (after map-locking the zone), whether or not the zone is virginal. If the client makes this determination, they should put a non-zero value into the first 32 bits of the zone (while the zone is still map-locked) to prevent subsequent clients of the zone from thinking the zone is still uninitialized.

Parameters:
pName the name of the SharedMemZone
nNumBytes the size of the SharedMemZone in bytes
bCreateIfNecessary whether or not to create the SharedMemZone if it doesn't already exist
Returns:
whether or not the Open() was successful
See also:
Close(), ~CascadeSharedMemZone()

MapLock()

bool CascadeSharedMemZone::Unlock  ) 
 

unlocks the SharedMemZone

Call Unlock() to unmap and release the shared memory zone. Calls to MapLock() may nest so be sure there is a corresponding call to Unlock() for every call to MapLock().

Returns:
whether or not the unlock was successful
See also:
MapLock()

Close(), ~CascadeSharedMemZone()


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:20 2005 for Cascade Library by  doxygen 1.4.1