![]() |
Bitcoin ABC 0.32.4
P2P Digital Currency
|
A helper class for interruptible sleeps. More...
#include <threadinterrupt.h>
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 |
A helper class for interruptible sleeps.
Calling operator() will interrupt any current sleep, and after that point operator bool() will return true until reset.
This class should not be used in a signal handler. It uses thread synchronization primitives that are not safe to use with signals. If sending an interrupt from a signal handler is necessary, the SignalInterrupt class can be used instead.
Definition at line 26 of file threadinterrupt.h.
| CThreadInterrupt::CThreadInterrupt | ( | ) |
Definition at line 8 of file threadinterrupt.cpp.
|
explicit |
Definition at line 10 of file threadinterrupt.cpp.
| void CThreadInterrupt::operator() | ( | ) |
Definition at line 18 of file threadinterrupt.cpp.
| void CThreadInterrupt::reset | ( | ) |
| bool CThreadInterrupt::sleep_for | ( | std::chrono::milliseconds | rel_time | ) |
| bool CThreadInterrupt::sleep_for | ( | std::chrono::minutes | rel_time | ) |
| bool CThreadInterrupt::sleep_for | ( | std::chrono::seconds | rel_time | ) |
Definition at line 33 of file threadinterrupt.cpp.
|
private |
Definition at line 40 of file threadinterrupt.h.
|
private |
Definition at line 42 of file threadinterrupt.h.
|
private |
Definition at line 41 of file threadinterrupt.h.