alarm

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alarm

type Alarm struct {
	Send    chan<- Event
	Receive <-chan Event
	// contains filtered or unexported fields
}

Alarm resends events at the requested time, or later. Closing the Send channel asks the alarm to terminate, which is notified by closing Receive.

func New

func New(chanSize int, opts ...Option) Alarm

New creates a new Alarm with the given size for Send. Receive is always unbuffered. Thus, settings chanSize to zero may result in deadlocks.

type Event

type Event struct {
	Time time.Time
	Data interface{}
	// Before resending the event, Remaining is set by Alarm to the number of remaining waiting events.
	Remaining int
}

type Option added in v0.0.7

type Option func(evt *Alarm)
var (
	// Events received by Alarm with Time greater than any waiting event are ignored.
	DiscardLaterEvent Option = func(evt *Alarm) {
		evt.discardLaterEvent = true
	}
)

Jump to

Keyboard shortcuts

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