Expand description
Process-global interrupt handling
This module contains facilities to globally request an interrupt, which will cause supporting computations to
abort once it is observed.
Such checks for interrupts are provided in custom implementations of various traits to transparently add interrupt
support to methods who wouldn’t otherwise by injecting it. see Read
.
Structs
- Deregister
interrupt
A type to help deregistering hooks registered withinit_handler
; - A wrapper for an inner iterator which will check for interruptions on each iteration.
- A wrapper for implementors of
std::io::Read
orstd::io::BufRead
with interrupt support.
Statics
- The flag behind all utility functions in this module.
Functions
- init_handler
interrupt
Initialize a signal handler to listen to SIGINT and SIGTERM and trigger ourtrigger()
that way. Also triggerinterrupt()
which promises to never use a Mutex, allocate or deallocate, or do anything else that’s blocking. Usegrace_count
to determine how often the termination signal can be received before it’s terminal, e.g. 1 would only terminate the application the second time the signal is received. Note that only thegrace_count
andinterrupt
of the first call are effective, all others will be ignored. - Returns true if an interrupt is requested.
- Sets the interrupt request to false, thus allowing those checking for
is_triggered()
to proceed. - Trigger an interrupt, signalling to those checking for
is_triggered()
to stop what they are doing.