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

Smart write pointer for a shared memory area. More...

#include <shmem.h>

Public Member Functions

 lockw (shmem< S, B > &mem_)
 
S * operator-> ()
 
 operator S* ()
 

Detailed Description

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

Smart write pointer for a shared memory area.

lockw objects can be used in code like this:

      struct DATA {
        int i;
      };

      shmem<DATA> mem("SHARED_DATA");
      try {
        lockw<DATA> wl(mem);
        wl->i = 2;
      }
      catch (runtime_error& err) {
        printf ("write lock failed\n");
      }

When created, the object places a write lock on the shared memory area that stays in place until the object is destroyed. The object can than be used as a (non-const) pointer to the structure in the shared memory area.


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