Thrill  0.1
onoff_switch Class Reference

Detailed Description

Definition at line 25 of file onoff_switch.hpp.

#include <onoff_switch.hpp>

Public Member Functions

 onoff_switch (bool flag=false)
 construct switch More...
 
 onoff_switch (const onoff_switch &)=delete
 non-copyable: delete copy-constructor More...
 
bool is_on ()
 return true if switch is ON More...
 
void off ()
 turn switch OFF and notify one waiter More...
 
void on ()
 turn switch ON and notify one waiter More...
 
onoff_switchoperator= (const onoff_switch &)=delete
 non-copyable: delete assignment operator More...
 
void wait_for_off ()
 wait for switch to turn OFF More...
 
void wait_for_on ()
 wait for switch to turn ON More...
 

Private Attributes

std::condition_variable cond_
 condition variable More...
 
std::mutex mutex_
 mutex for condition variable More...
 
bool on_
 the switch's state More...
 

Constructor & Destructor Documentation

◆ onoff_switch() [1/2]

onoff_switch ( bool  flag = false)
inlineexplicit

construct switch

Definition at line 38 of file onoff_switch.hpp.

References onoff_switch::operator=().

◆ onoff_switch() [2/2]

onoff_switch ( const onoff_switch )
delete

non-copyable: delete copy-constructor

Member Function Documentation

◆ is_on()

bool is_on ( )
inline

return true if switch is ON

Definition at line 80 of file onoff_switch.hpp.

References onoff_switch::on_.

◆ off()

void off ( )
inline

turn switch OFF and notify one waiter

Definition at line 56 of file onoff_switch.hpp.

◆ on()

void on ( )
inline

turn switch ON and notify one waiter

Definition at line 48 of file onoff_switch.hpp.

Referenced by request_with_waiters::notify_waiters(), and set_switch_handler::operator()().

◆ operator=()

onoff_switch& operator= ( const onoff_switch )
delete

non-copyable: delete assignment operator

Referenced by onoff_switch::onoff_switch().

◆ wait_for_off()

void wait_for_off ( )
inline

wait for switch to turn OFF

Definition at line 72 of file onoff_switch.hpp.

◆ wait_for_on()

void wait_for_on ( )
inline

wait for switch to turn ON

Definition at line 64 of file onoff_switch.hpp.

Referenced by block_prefetcher< BlockType, BidIteratorType >::wait(), and foxxll::wait_any().

Member Data Documentation

◆ cond_

std::condition_variable cond_
private

condition variable

Definition at line 31 of file onoff_switch.hpp.

◆ mutex_

std::mutex mutex_
private

mutex for condition variable

Definition at line 28 of file onoff_switch.hpp.

◆ on_

bool on_
private

the switch's state

Definition at line 34 of file onoff_switch.hpp.

Referenced by onoff_switch::is_on().


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