Module gix::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

Statics

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.
  • 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.