fakeclock

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 3 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 fakeclock provides a manually advanced stream.Clock for tests of the batch-mode wait: no test needs to sleep for a real maxWaitMs.

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 stream.Clock whose time only moves when Advance is called.

func New

func New() *Clock

New returns a clock at an arbitrary fixed instant.

func (*Clock) Active

func (c *Clock) Active() int

Active returns the number of timers that were created and not stopped.

func (*Clock) Advance

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

Advance moves the clock forward and fires every timer that is due.

func (*Clock) AwaitTimers

func (c *Clock) AwaitTimers(n int, timeout time.Duration) bool

AwaitTimers blocks until at least n timers have been created in total, or the timeout expires; it reports whether the count was reached. It lets a test wait for "the reader is now waiting on its timer" without sleeping.

func (*Clock) Created

func (c *Clock) Created() int

Created returns the number of timers created so far.

func (*Clock) NewTimer

func (c *Clock) NewTimer(d time.Duration) stream.Timer

NewTimer implements stream.Clock.

func (*Clock) Now

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

Now implements stream.Clock.

Jump to

Keyboard shortcuts

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