MOTION  0.01
Framework for mixed-protocol multi-party computation
Public Member Functions | List of all members
encrypto::motion::Condition Class Reference

Wraps a std::condition_variable with a std::mutex and a condition checking function. More...

#include <condition.h>

Public Member Functions

 ~Condition ()=default
 
 Condition ()=delete
 
 Condition (Condition &)=delete
 
 Condition (const std::function< bool()> condition_function)
 Registers the condition function that encapsulates the condition checking. More...
 
bool operator() ()
 checks if the condition was satisfied More...
 
bool Wait ()
 Blocks until thread is notified and condition_function_ returns true. More...
 
template<typename Tick , typename Period >
bool WaitFor (std::chrono::duration< Tick, Period > duration)
 Blocks until thread is notified and condition_function_ returns true or duration time has passed. More...
 
void NotifyOne () noexcept
 Unblocks one thread waiting for condition_variable_. More...
 
void NotifyAll () noexcept
 Unblocks all threads waiting for condition_variable_. More...
 
std::mutex & GetMutex () noexcept
 Get the mutex. More...
 

Detailed Description

Wraps a std::condition_variable with a std::mutex and a condition checking function.

Constructor & Destructor Documentation

◆ ~Condition()

encrypto::motion::Condition::~Condition ( )
default

◆ Condition() [1/3]

encrypto::motion::Condition::Condition ( )
delete

◆ Condition() [2/3]

encrypto::motion::Condition::Condition ( Condition )
delete

◆ Condition() [3/3]

encrypto::motion::Condition::Condition ( const std::function< bool()>  condition_function)
inline

Registers the condition function that encapsulates the condition checking.

Parameters
condition_function

Member Function Documentation

◆ GetMutex()

std::mutex& encrypto::motion::Condition::GetMutex ( )
inlinenoexcept

Get the mutex.

Note
The variables that the condition function depends on shall only be modified under the locked mutex.

◆ NotifyAll()

void encrypto::motion::Condition::NotifyAll ( )
inlinenoexcept

Unblocks all threads waiting for condition_variable_.

◆ NotifyOne()

void encrypto::motion::Condition::NotifyOne ( )
inlinenoexcept

Unblocks one thread waiting for condition_variable_.

◆ operator()()

bool encrypto::motion::Condition::operator() ( )
inline

checks if the condition was satisfied

◆ Wait()

bool encrypto::motion::Condition::Wait ( )

Blocks until thread is notified and condition_function_ returns true.

◆ WaitFor()

template<typename Tick , typename Period >
bool encrypto::motion::Condition::WaitFor ( std::chrono::duration< Tick, Period >  duration)
inline

Blocks until thread is notified and condition_function_ returns true or duration time has passed.

Parameters
duration

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