The default constructor initializes an FBB::SharedMutex object to a shared memory mutex (using the PTHREAD_PROCESS_SHARED attribute). As an FBB::SharedMutex object will normally be defined inside a shared memory segment the objects memory is already available. In this case placement new should be used to call the constructor. E.g., if a shared memory segment is attached to the current process at d_shared, and an FBB::SharedMutex should be defined at d_shareds address, then the FBB::SharedMutex object can be initialized like this:
Caveat: when using placement new to initialize a SharedMutex make sure that the SharedMutex fits inside a block (i.e., shared.blockOffset() + sizeof(SharedMemory) < shared.dataSegmentSize()). If not, use seek to switch to an offset where this equality holds true, or simply use SharedMemory::create like this:
The classs destructor releases all of the current processs nested shared memory segment locks. To destroy an FBB::SharedMutex object that has been constructed using the placement new operator use
(assuming SharedMutex *d_sharedMutex points to the location where placement new has previously initialized the FBB::SharedMutex object.)
|Copy and move constructors are not available.|
o void lock() const:
When returning from this member, the current process has locked the shared memory segment. Note that SharedMutex objects are non-recursive.
o void unlock() const:
The objects lock of the shared memory segment is released. This member can also be called if the SharedMutexs lock has not been obtained.
o pthread_mutex_t *mutexPtr():
A pointer is returned to the pthread_mutex_t object used by the SharedMutex object;
See the sharedstream(3bobcat) man page.
bobcat/sharedmutex - defines the class interface
bobcat(7) isharedstream(3bobcat), osharedstream(3bobcat), sharedblock(3bobcat), sharedcondition(3bobcat), sharedmemory(3bobcat), (e.g.,) pthread_mutex_init(3posix), sharedpos(3bobcat), sharedreadme(7bobcat), sharedsegment(3bobcat), sharedstream(3bobcat), sharedstreambuf(3bobcat)
o bobcat_3.25.01-x.dsc: detached signature; o bobcat_3.25.01-x.tar.gz: source archive; o bobcat_3.25.01-x_i386.changes: change log; o libbobcat1_3.25.01-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.25.01-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location;
Bobcat is an acronym of Brokkens Own Base Classes And Templates.
This is free software, distributed under the terms of the GNU General Public License (GPL).
Frank B. Brokken (firstname.lastname@example.org).