Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Module interrupt

Module interrupt 

Source
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§

Deregisterinterrupt
A type to help deregistering hooks registered with init_handler;
Iter
A wrapper for an inner iterator which will check for interruptions on each iteration.
Read
A wrapper for implementers of std::io::Read or std::io::BufRead with interrupt support.

Statics§

IS_INTERRUPTED
The flag behind all utility functions in this module.

Functions§

init_handlerinterrupt
Initialize a signal handler to listen to SIGINT and SIGTERM and trigger our trigger() that way. Also trigger interrupt() which promises to never use a Mutex, allocate or deallocate, or do anything else that’s blocking. Use grace_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 the grace_count and interrupt of the first call are effective, all others will be ignored.
is_triggered
Returns true if an interrupt is requested.
reset
Sets the interrupt request to false, thus allowing those checking for is_triggered() to proceed.
trigger
Trigger an interrupt, signalling to those checking for is_triggered() to stop what they are doing.