Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cx::SharedMemoryServer Class Reference

Shared Memory Server. More...

#include <cxSharedMemory.h>

Public Member Functions

 SharedMemoryServer (QString key, int buffers, int sizeEach, QObject *parent=0)
 
 ~SharedMemoryServer ()
 
int size ()
 
int buffers ()
 
QString key ()
 
void * buffer ()
 Grab and lock a write buffer. More...
 
void release ()
 Release our write buffer. Buffer will not be used before it is released. More...
 
QDateTime lastTimestamp ()
 
bool hasBuffer ()
 

Detailed Description

Shared Memory Server.

Implements a circular buffer in shared memory using a client-server model, where you have one writer and potentially multiple readers. Note that if you have more readers than buffers, you can end up with all buffers busy when you want to write new data. Readers always grab the latest buffer. Things go more smooth when all users release their buffers as soon as they are done.Implements a circular buffer in shared memory using a client-server model, where you have one writer and potentially multiple readers. Note that if you have more readers than buffers, you can end up with all buffers busy when you want to write new data. Readers always grab the latest buffer. Things go more smooth when all users release their buffers as soon as they are done.

See Also
SharedMemoryClient

Definition at line 61 of file cxSharedMemory.h.

Constructor & Destructor Documentation

cx::SharedMemoryServer::SharedMemoryServer ( QString  key,
int  buffers,
int  sizeEach,
QObject *  parent = 0 
)

Constructor.

Parameters
keyA string identifying this resource. Must be unique system wide
buffersThe number of buffers to allocate. This should be set to the maximum number of concurrent readers to this resource + 2, allowing one buffer for the writer (this class), one for each reader and a spare so there is always a buffer for the writer to switch to.
sizeEachThe size of each buffer.
parentThe Qt parent object

Definition at line 49 of file cxSharedMemory.cpp.

cx::SharedMemoryServer::~SharedMemoryServer ( )

Definition at line 81 of file cxSharedMemory.cpp.

Member Function Documentation

void * cx::SharedMemoryServer::buffer ( )

Grab and lock a write buffer.

Definition at line 86 of file cxSharedMemory.cpp.

int cx::SharedMemoryServer::buffers ( )
inline

Definition at line 83 of file cxSharedMemory.h.

bool cx::SharedMemoryServer::hasBuffer ( )
inline

Return true if a write buffer is currently held, false otherwise

Definition at line 94 of file cxSharedMemory.h.

QString cx::SharedMemoryServer::key ( )
inline

Definition at line 84 of file cxSharedMemory.h.

QDateTime cx::SharedMemoryServer::lastTimestamp ( )
inline

Return the timestamp of the last buffer written to

Definition at line 90 of file cxSharedMemory.h.

void cx::SharedMemoryServer::release ( )

Release our write buffer. Buffer will not be used before it is released.

Definition at line 144 of file cxSharedMemory.cpp.

int cx::SharedMemoryServer::size ( )
inline

Definition at line 82 of file cxSharedMemory.h.


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