Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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 209 of file sync.hpp.

Classes

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

Static Public Member Functions

static MonitorgetMonitor (Sync const *forThis)
 

Private Types

using Monitor = sync::Monitor< CONF >
 

Private Attributes

Monitor objectMonitor_
 

Member Typedef Documentation

◆ Monitor

template<class CONF = NonrecursiveLock_NoWait>
using Monitor = sync::Monitor<CONF>
private

Definition at line 211 of file sync.hpp.

Member Function Documentation

◆ getMonitor()

template<class CONF = NonrecursiveLock_NoWait>
static Monitor & getMonitor ( Sync< CONF > const *  forThis)
inlinestatic

Definition at line 216 of file sync.hpp.

References Sync< CONF >::objectMonitor_.

Member Data Documentation

◆ objectMonitor_

template<class CONF = NonrecursiveLock_NoWait>
Monitor objectMonitor_
mutableprivate

Definition at line 212 of file sync.hpp.

Referenced by Sync< CONF >::getMonitor().

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

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