Lumiera  0.pre.03
»edit your freedom«
Sync< CONF > Class Template Reference

#include "lib/sync.hpp"

Description

template<class CONF = NonrecursiveLock_NoWait>
class lib::Sync< CONF >

Facility for monitor object based locking.

To be attached either on a per class base or per object base. Typically, the client class will inherit from this template (but it is possible to use it stand-alone, if inheriting isn't an option). The interface for clients to access the functionality is the embedded Lock template, which should be instantiated as an automatic variable within the scope to be protected.

Usage

  • for locking, just place an instant of the embedded Lock into the local scope to be protected. All lock instances within the same object share the monitor; thus any time, only one of them gets the mutex all other instances block on construction.
  • for waiting likewise place an instance of the Lock class (which gets you a mutex). Then invoke the wait method on that instance; this suspends the current thread and releases the mutex. To awake and check the condition, some other thread must invoke the Lock::notify() within the same object. The Lock::wait() call returns true when the condition was met, and false if awakened due to timeout. The call might throw in case of technical errors. In any case, when returning from the wait() call, the mutex has been re-acquired.

Definition at line 217 of file sync.hpp.

Static Public Member Functions

static MonitorgetMonitor (Sync const *forThis)
 

Classes

class  Lock
 scoped guard to control the actual locking. More...
 

Private Types

using Monitor = sync::Monitor< CONF >
 

Private Attributes

Monitor objectMonitor_
 
+ Inheritance diagram for Sync< CONF >:
+ Collaboration diagram for Sync< CONF >:

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