timers

package
v0.0.0-...-d1a9080 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimerStore

type TimerStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TimerStore describes a timer store.

A timer store keeps track of timers in a map. A finished timer is always removed from the map after its execution.

func NewTimerStore

func NewTimerStore() *TimerStore

NewTimerStore creates a new TimerStore.

func (*TimerStore) Exists

func (ts *TimerStore) Exists(id interface{}) bool

Exists returns true if a timer is running for the given ID.

func (*TimerStore) Start

func (ts *TimerStore) Start(id interface{}, duration time.Duration, f func())

Start starts a new timer that will execute the given function "f" after "duration". It stores the time.Timer in the store and removes it when the function finishes.

func (*TimerStore) Stop

func (ts *TimerStore) Stop(id interface{}) (res bool)

Stop cancels a timer and removes it from the store.

Jump to

Keyboard shortcuts

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