[#CThreadInterrupt] = CThreadInterrupt :mrdocs: 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>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 xref:util/SignalInterrupt.adoc[`util::SignalInterrupt`] class can be used instead. == Type Aliases [cols="1,4"] |=== | Name| Description | xref:CThreadInterrupt/Clock.adoc[`Clock`] | Clock used to measure sleep durations. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:CThreadInterrupt/2constructor.adoc[`CThreadInterrupt`] [.small]#[constructor]# | Constructs an interrupt in the non‐interrupted state. | xref:CThreadInterrupt/2destructor.adoc[`~CThreadInterrupt`] [.small]#[destructor]# [.small]#[virtual]# | Destroys the interrupt. | xref:CThreadInterrupt/interrupted.adoc[`interrupted`] [.small]#[virtual]# | Reports whether an interrupt has been requested. | xref:CThreadInterrupt/operator_call.adoc[`operator()`] [.small]#[virtual]# | Interrupt any sleeps. After this `interrupted()` will return `true`. | xref:CThreadInterrupt/reset.adoc[`reset`] [.small]#[virtual]# | Reset to an non‐interrupted state. | xref:CThreadInterrupt/sleep_for.adoc[`sleep_for`] [.small]#[virtual]# | Sleep for the given duration, returning early if interrupted. | xref:CThreadInterrupt/2conversion.adoc[`operator bool`] [.small]#[virtual]# | An alias for `interrupted()`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#