mclock

package
v0.0.0-...-d5477c9 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package mclock is a wrapper for a monotonic clock source

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsTime

type AbsTime time.Duration

AbsTime represents absolute monotonic time.

func Now

func Now() AbsTime

Now returns the current absolute monotonic time.

func (AbsTime) Add

func (t AbsTime) Add(d time.Duration) AbsTime

Add returns t + d.

type Clock

type Clock interface {
	Now() AbsTime
	Sleep(time.Duration)
	After(time.Duration) <-chan time.Time
	AfterFunc(d time.Duration, f func()) Event
}

Clock interface makes it possible to replace the monotonic system clock with a simulated clock.

type Event

type Event interface {
	Cancel() bool
}

Event represents a cancellable event returned by AfterFunc

type System

type System struct{}

System implements Clock using the system clock.

func (System) After

func (System) After(d time.Duration) <-chan time.Time

After implements Clock.

func (System) AfterFunc

func (System) AfterFunc(d time.Duration, f func()) Event

AfterFunc implements Clock.

func (System) Now

func (System) Now() AbsTime

Now implements Clock.

func (System) Sleep

func (System) Sleep(d time.Duration)

Sleep implements Clock.

type SystemEvent

type SystemEvent time.Timer

SystemEvent implements Event using time.Timer.

func (*SystemEvent) Cancel

func (e *SystemEvent) Cancel() bool

Cancel implements Event.

Jump to

Keyboard shortcuts

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