MLIB
|
Shared memory area with support for single-writer multiple-readers. More...
#include <shmem.h>
Public Member Functions | |
shmem () | |
Default constructor. | |
shmem (const char *name) | |
Creates and opens a shared memory area with the given name. | |
bool | open (const char *name, size_t sz=sizeof(S)) |
Opens a shared memory area. | |
void | operator>> (S &data) |
Read the content of shared memory area. | |
void | operator<< (const S &data) |
Update (write) the content of a shared memory area. | |
![]() | |
shmem_base () | |
Default constructor. | |
shmem_base (const std::string &name, size_t size) | |
Create and open a SMA. | |
virtual | ~shmem_base () |
Destructor. | |
virtual bool | open (const std::string &name, size_t size) |
Open a SMA. | |
virtual bool | close () |
Close a SMA. | |
bool | created () const |
bool | is_opened () const |
Return true if shared memory is opened. | |
size_t | size () const |
Return size of shared memory area. | |
const std::string & | name () const |
Return the name of the shared memory area. | |
void | wtmo (DWORD msec) |
Set timeout value for write operations. | |
DWORD | wtmo () const |
Return current write timeout value (in milliseconds) | |
void | rtmo (DWORD msec) |
Set timeout value for read operations. | |
DWORD | rtmo () const |
Return current timeout value for read operations (in milliseconds) | |
virtual bool | write (const void *data) |
Obtain writer lock and update SMA. | |
virtual bool | read (void *data) |
Obtain a reader lock and retrieve SMA content. | |
Protected Member Functions | |
const S * | dataptr () const |
Return a pointer to content of SMA (const variant) | |
S * | dataptr () |
Return a pointer to content of SMA (const variant) | |
![]() | |
virtual bool | rdlock () |
Obtain a reader lock on SMA. | |
virtual void | rdunlock () |
Release a previously obtained reader lock. | |
virtual bool | wrlock () |
Obtain a writer lock on SMA. | |
virtual void | wrunlock () |
Release a previously obtained writer lock. | |
void | get (void *data) const |
Retrieve current content of SMA. | |
void | put (const void *data) |
Write new data into the SMA. | |
const void * | dataptr () const |
Return a pointer to content of SMA (const variant) | |
void * | dataptr () |
Return a pointer to content of SMA (non-const variant) | |
Friends | |
template<class S, class B> | |
class | lockr |
template<class S, class B> | |
class | lockw |
Shared memory area with support for single-writer multiple-readers.