Fraxinus
16.5.0-fx-rc3
An IGT application
|
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 () |
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.
Definition at line 61 of file cxSharedMemory.h.
cx::SharedMemoryServer::SharedMemoryServer | ( | QString | key, |
int | buffers, | ||
int | sizeEach, | ||
QObject * | parent = 0 |
||
) |
Constructor.
key | A string identifying this resource. Must be unique system wide |
buffers | The 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. |
sizeEach | The size of each buffer. |
parent | The Qt parent object |
Definition at line 49 of file cxSharedMemory.cpp.
cx::SharedMemoryServer::~SharedMemoryServer | ( | ) |
Definition at line 81 of file cxSharedMemory.cpp.
void * cx::SharedMemoryServer::buffer | ( | ) |
Grab and lock a write buffer.
Definition at line 86 of file cxSharedMemory.cpp.
|
inline |
Definition at line 83 of file cxSharedMemory.h.
|
inline |
Return true if a write buffer is currently held, false otherwise
Definition at line 94 of file cxSharedMemory.h.
|
inline |
Definition at line 84 of file cxSharedMemory.h.
|
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.
|
inline |
Definition at line 82 of file cxSharedMemory.h.