[#CThreadInterrupt]
= CThreadInterrupt
:mrdocs:

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

== Synopsis

Declared in `&lt;util&sol;threadinterrupt&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CThreadInterrupt;
----

== Description

This class should not be used in a signal handler&period; It uses thread synchronization primitives that are not safe to use with signals&period; If sending an interrupt from a signal handler is necessary, the xref:util/SignalInterrupt.adoc[`util&colon;&colon;SignalInterrupt`] class can be used instead&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:CThreadInterrupt/Clock.adoc[`Clock`] 
| Clock used to measure sleep durations&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CThreadInterrupt/2constructor.adoc[`CThreadInterrupt`]         [.small]#[constructor]#
| Constructs an interrupt in the non&hyphen;interrupted state&period;
| xref:CThreadInterrupt/2destructor.adoc[`&#126;CThreadInterrupt`] [.small]#[destructor]# [.small]#[virtual]#
| Destroys the interrupt&period;
| xref:CThreadInterrupt/interrupted.adoc[`interrupted`]  [.small]#[virtual]#
| Reports whether an interrupt has been requested&period;
| xref:CThreadInterrupt/operator_call.adoc[`operator()`]  [.small]#[virtual]#
| Interrupt any sleeps&period; After this `interrupted()` will return `true`&period;
| xref:CThreadInterrupt/reset.adoc[`reset`]  [.small]#[virtual]#
| Reset to an non&hyphen;interrupted state&period;
| xref:CThreadInterrupt/sleep_for.adoc[`sleep&lowbar;for`]  [.small]#[virtual]#
| Sleep for the given duration, returning early if interrupted&period;
| xref:CThreadInterrupt/2conversion.adoc[`operator bool`]  [.small]#[virtual]#
| An alias for `interrupted()`&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
