Base class for shared memory objects.
More...
#include <shmem.h>
|
| 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 |
|
size_t | size () const |
|
const std::string & | name () const |
|
void | wtmo (DWORD msec) |
|
DWORD | wtmo () const |
|
void | rtmo (DWORD msec) |
|
DWORD | rtmo () const |
|
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.
|
|
|
bool | rdlock () |
| Obtain a reader lock on SMA.
|
|
void | rdunlock () |
| Release a previously obtained reader lock.
|
|
bool | wrlock () |
| Obtain a writer lock on SMA.
|
|
void | wrunlock () |
| Release a previously obtained writer lock.
|
|
virtual void | get (void *data) |
| Retrieve current content of SMA.
|
|
virtual void | put (const void *data) |
| Write new data into the SMA.
|
|
void * | dataptr () const |
|
Base class for shared memory objects.
◆ shmem_base() [1/2]
mlib::shmem_base::shmem_base |
( |
| ) |
|
Default constructor.
The shared memory area (SMA) must be opened before use.
◆ shmem_base() [2/2]
mlib::shmem_base::shmem_base |
( |
const std::string & | nam, |
|
|
size_t | sz_ ) |
Create and open a SMA.
- Parameters
-
nam | name of SMA |
sz_ | size of SMA (not including size of synchronization stuff) |
◆ ~shmem_base()
mlib::shmem_base::~shmem_base |
( |
| ) |
|
|
virtual |
Destructor.
If SMA was opened, close it now.
◆ open()
bool mlib::shmem_base::open |
( |
const std::string & | nam, |
|
|
size_t | sz_ ) |
|
virtual |
Open a SMA.
- Parameters
-
nam | name of SMA |
sz_ | size of SMA (not including size of synchronization stuff) |
The SMA is called <nam>.MEM
. Additionally, the following objects are created:
- event flag
<nam>.EVT
- Mutex
<nam>.MUT
◆ rdlock()
bool mlib::shmem_base::rdlock |
( |
| ) |
|
|
protected |
Obtain a reader lock on SMA.
- Returns
true
if successful, false
otherwise
If a write operation is in progress, the function waits for it to complete before acquiring read lock. If it cannot obtain the lock in read timeout set, the function returns false
.
◆ read()
bool mlib::shmem_base::read |
( |
void * | pData | ) |
|
|
virtual |
Obtain a reader lock and retrieve SMA content.
- Parameters
-
◆ write()
bool mlib::shmem_base::write |
( |
const void * | pData | ) |
|
|
virtual |
Obtain writer lock and update SMA.
- Parameters
-
pData | pointer to data to write in SMA |
◆ wrlock()
bool mlib::shmem_base::wrlock |
( |
| ) |
|
|
protected |
Obtain a writer lock on SMA.
- Returns
- true if successful, false otherwise
If another operation is in progress, the function waits for it to complete before acquiring write lock. If it cannot obtain the lock in write timeout set, the function returns false.
The documentation for this class was generated from the following files: