timer

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package timer provides a resettable timer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResettableTimer

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

ResettableTimer wraps time.Timer to allow resetting the timer to any duration.

func (*ResettableTimer) C

func (rt *ResettableTimer) C() <-chan time.Time

C returns the timer channel.

If the timer was not reset to a non-zero duration, nil is returned.

func (*ResettableTimer) Clear

func (rt *ResettableTimer) Clear()

Clear should be called after receiving from the timer channel.

func (*ResettableTimer) Reset

func (rt *ResettableTimer) Reset(delay time.Duration)

Reset resets the timer to the given duration.

If the duration is zero, the timer is removed (and stopped as needed). If the duration is non-zero, the timer is created if it doesn't exist, or reset if it does.

Jump to

Keyboard shortcuts

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