testclock

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testclock is a fake clock for tests: time moves only on Advance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

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

Clock is a fake core.Clock. Its timers fire in Advance, in deadline order, on the goroutine calling it.

func New

func New(now time.Time) *Clock

New is a Clock reading now until advanced.

func (*Clock) Advance

func (c *Clock) Advance(d time.Duration)

Advance moves the clock forward by d, firing each timer that comes due with Now at its deadline, including timers those callbacks set.

func (*Clock) AfterFunc

func (c *Clock) AfterFunc(d time.Duration, f func()) (stop func() bool)

AfterFunc calls f once the clock is advanced by d or more. As with time.AfterFunc, d <= 0 calls it at once in its own goroutine.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now is the clock's current time.

Jump to

Keyboard shortcuts

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