MLIB
Loading...
Searching...
No Matches
mlib::lockr< S, B > Class Template Reference

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 * ()
 

Detailed Description

template<class S, class B = shmem_base>
class mlib::lockr< S, B >

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.


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