CThreadInterrupt

A helper class for interruptible sleeps. Calling operator() will interrupt any current sleep, and after that point operator bool() will return true until reset.

Synopsis

Declared in <util/threadinterrupt.h>

class CThreadInterrupt;

Description

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 util::SignalInterrupt class can be used instead.

Type Aliases

NameDescription
Clock Clock used to measure sleep durations.

Member Functions

NameDescription
CThreadInterrupt [constructor]Constructs an interrupt in the non-interrupted state.
~CThreadInterrupt [destructor] [virtual]Destroys the interrupt.
interrupted [virtual]Reports whether an interrupt has been requested.
operator() [virtual]Interrupt any sleeps. After this interrupted() will return true.
reset [virtual]Reset to an non-interrupted state.
sleep_for [virtual]Sleep for the given duration, returning early if interrupted.
operator bool [virtual]An alias for interrupted().