Documentation
¶
Overview ¶
Package interrupt provides access to hardware interrupts. It provides a way to define interrupts and to enable/disable them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Checkpoint ¶ added in v0.38.0
type Checkpoint struct {
// contains filtered or unexported fields
}
A checkpoint is a setjmp like buffer, that can be used as a flag for interrupts.
It can be used as follows:
// global var var c Checkpoint // to set up the checkpoint and wait for it if c.Save() { setupInterrupt() for { waitForInterrupt() } } // Inside the interrupt handler: if c.Saved() { c.Jump() }
func (*Checkpoint) Jump ¶ added in v0.38.0
func (c *Checkpoint) Jump()
Jump to the point where the execution state was saved, and erase the saved jump point. This must *only* be called from inside an interrupt.
This method does not return in the conventional way, it resumes execution at the last point a checkpoint was saved.
func (*Checkpoint) Save ¶ added in v0.38.0
func (c *Checkpoint) Save() bool
Save the execution state in the given checkpoint, overwriting a previous saved checkpoint.
This function returns twice: once the normal way after saving (returning true) and once after jumping (returning false).
This function is a compiler intrinsic, it is not implemented in Go.
func (*Checkpoint) Saved ¶ added in v0.38.0
func (c *Checkpoint) Saved() bool
Returns whether a jump point was saved (and not erased due to a jump).
type Interrupt ¶
type Interrupt struct {
// contains filtered or unexported fields
}
Interrupt provides direct access to hardware interrupts. You can configure this interrupt through this interface.
Do not use the zero value of an Interrupt object. Instead, call New to obtain an interrupt handle.
type State ¶ added in v0.14.0
type State uintptr
State represents the previous global interrupt state.
func Disable ¶ added in v0.14.0
func Disable() (state State)
Disable disables all interrupts and returns the previous interrupt state. It can be used in a critical section like this:
state := interrupt.Disable() // critical section interrupt.Restore(state)
Critical sections can be nested. Make sure to call Restore in the same order as you called Disable (this happens naturally with the pattern above).