|
MLIB
|
Smart read pointer for a shared memory area. More...
#include <shmem.h>
Public Member Functions | |
| lockr (shmem< S, B > &mem_) | |
| const S * | operator-> () |
| operator const S * () | |
Smart read pointer for a shared memory area.
lockr objects can be used in code like this:
struct DATA {
int i;
};
shmem<DATA> mem("SHARED_DATA");
int li;
try {
lockr<DATA> rl(mem);
li = rl->i;
}
catch (runtime_error& err) {
printf ("read lock failed\n");
}
When created, the object places a read lock on the shared memory area that stays in place until the object is destroyed. The object can than be used as a const pointer to the structure in the shared memory area.