timer

package
v0.0.0-...-2a45ea8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package timer provides abstract interfaces to represent an event of elapsed time. It also provides implementation of those interfaces using Timer type from the standard time package. These interfaces make it easier to implement unit tests for components that operate with timeout events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	// NewTimer creates a new Timer that is to expire at least
	// after duration d.
	NewTimer(d time.Duration) Timer

	// AfterFunc creates a new Timer that is to expire at least
	// after duration d. The supplied callback function f is
	// invoked in a spawned goroutine upon the timer expiration.
	AfterFunc(d time.Duration, f func()) Timer
}

Provider is an interface of abstract timer implementation.

func Standard

func Standard() Provider

Standard returns standard timer implementation.

type Timer

type Timer interface {
	// Expired returns a channel to receive the current time when
	// the timer expires.
	Expired() <-chan time.Time

	// Reset reschedules the timer to expire after duration d. It
	// should only be used on an inactive timer.
	Reset(d time.Duration)

	// Stop cancels the timer. It returns true if the timer has
	// been stopped by this invocation before expiration.
	Stop() bool
}

Timer is an interface to manipulate with an event of elapsed time.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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