Bitcoin ABC  0.28.12
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
CThreadInterrupt Class Reference

A helper class for interruptible sleeps. More...

#include <threadinterrupt.h>

Collaboration diagram for CThreadInterrupt:
[legend]

Public Member Functions

 CThreadInterrupt ()
 
 operator bool () const
 
void operator() () EXCLUSIVE_LOCKS_REQUIRED(!mut)
 
void reset ()
 
bool sleep_for (std::chrono::milliseconds rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut)
 
bool sleep_for (std::chrono::seconds rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut)
 
bool sleep_for (std::chrono::minutes rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut)
 

Private Attributes

std::condition_variable cond
 
Mutex mut
 
std::atomic< bool > flag
 

Detailed Description

A helper class for interruptible sleeps.

Calling operator() will interrupt any current sleep, and after that point operator bool() will return true until reset.

Definition at line 19 of file threadinterrupt.h.

Constructor & Destructor Documentation

◆ CThreadInterrupt()

CThreadInterrupt::CThreadInterrupt ( )

Definition at line 8 of file threadinterrupt.cpp.

Member Function Documentation

◆ operator bool()

CThreadInterrupt::operator bool ( ) const
explicit

Definition at line 10 of file threadinterrupt.cpp.

◆ operator()()

void CThreadInterrupt::operator() ( )

Definition at line 18 of file threadinterrupt.cpp.

◆ reset()

void CThreadInterrupt::reset ( )

Definition at line 14 of file threadinterrupt.cpp.

Here is the caller graph for this function:

◆ sleep_for() [1/3]

bool CThreadInterrupt::sleep_for ( std::chrono::milliseconds  rel_time)

Definition at line 26 of file threadinterrupt.cpp.

Here is the caller graph for this function:

◆ sleep_for() [2/3]

bool CThreadInterrupt::sleep_for ( std::chrono::minutes  rel_time)

Definition at line 38 of file threadinterrupt.cpp.

Here is the call graph for this function:

◆ sleep_for() [3/3]

bool CThreadInterrupt::sleep_for ( std::chrono::seconds  rel_time)

Definition at line 33 of file threadinterrupt.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ cond

std::condition_variable CThreadInterrupt::cond
private

Definition at line 33 of file threadinterrupt.h.

◆ flag

std::atomic<bool> CThreadInterrupt::flag
private

Definition at line 35 of file threadinterrupt.h.

◆ mut

Mutex CThreadInterrupt::mut
private

Definition at line 34 of file threadinterrupt.h.


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