mytimer

package
v1.54.10 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func = func() TimeValue

type TimeValue

type TimeValue struct {
	time.Time
}

The timer deadline. Zero value is a special case it means it won't fire at all.

func FromTime

func FromTime(t time.Time) TimeValue

func Immediate

func Immediate() TimeValue

func Never

func Never() (_ TimeValue)

type Timer

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

Very common pattern I have in my code, a timer that coordinates resets from the callback function, externally, and tracks when it's due. Only one instance of the timer callback can be running at a time, and that callback is responsible for also returning the next delay.

func (*Timer) Init

func (me *Timer) Init(first TimeValue, f Func)

func (*Timer) Update

func (me *Timer) Update(when TimeValue)

Resets if the timer func hasn't fired.

func (*Timer) When

func (me *Timer) When() TimeValue

Jump to

Keyboard shortcuts

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