interrupt

package
v0.0.0-...-9ec6d29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package interrupt provides an interrupt helper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Forwarder

type Forwarder struct {
	// contains filtered or unexported fields
}

Forwarder is a helper for delivering delayed signal interruptions.

This helps platform implementations with Interrupt semantics.

func (*Forwarder) Disable

func (f *Forwarder) Disable()

Disable stops interrupt forwarding. If interrupt forwarding is already disabled, Disable is a no-op.

func (*Forwarder) Enable

func (f *Forwarder) Enable(r Receiver) bool

Enable attempts to enable interrupt forwarding to r. If f has already received an interrupt, Enable does nothing and returns false. Otherwise, future calls to f.NotifyInterrupt() cause r.NotifyInterrupt() to be called, and Enable returns true.

Usage:

if !f.Enable(r) {
	// There was an interrupt.
	return
}

defer f.Disable()

Preconditions:

  • r must not be nil.
  • f must not already be forwarding interrupts to a Receiver.

func (*Forwarder) NotifyInterrupt

func (f *Forwarder) NotifyInterrupt()

NotifyInterrupt implements Receiver.NotifyInterrupt. If interrupt forwarding is enabled, the configured Receiver will be notified. Otherwise the interrupt will be delivered to the next call to Enable.

type Receiver

type Receiver interface {
	// NotifyInterrupt is called when the Receiver receives an interrupt.
	NotifyInterrupt()
}

Receiver receives interrupt notifications from a Forwarder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL