clock

package
v0.0.0-...-155060c Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2017 License: BSD-2-Clause Imports: 3 Imported by: 1

Documentation

Overview

Package clock provides various Clock implementations that mesure time according to various cronometers available.

See also https://groups.google.com/d/msg/golang-nuts/D11F4zMs-E0/Nnh6W6nN-3YJ

Index

Constants

View Source
const (
	CLOCK_REALTIME = iota
	CLOCK_MONOTONIC
	CLOCK_PROCESS_CPUTIME_ID
	CLOCK_THREAD_CPUTIME_ID
	CLOCK_MONOTONIC_RAW
	CLOCK_REALTIME_COARSE
	CLOCK_MONOTONIC_COARSE
	CLOCK_BOOTTIME
	CLOCK_REALTIME_ALARM
	CLOCK_BOOTTIME_ALARM
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {

	// Now returns the current time according to this Clock
	Now() time.Time
}

A Clock represents a cronometer which can be queried for a time.Time value.

var (
	// System-wide clock that measures real (i.e., wall-clock) time.
	// This clock is affected by discontinuous jumps in the system time (e.g., if
	// the system administrator manually changes the clock), and by the incremental
	// adjustments performed by adjtime(3) and NTP.
	Realtime Clock = &clock{CLOCK_REALTIME}

	// Clock that cannot be set and represents monotonic time since some unspecified
	// starting point. This clock is not affected by discontinuous jumps in the
	// system time (e.g., if the system administrator manually changes the clock),
	// but is affected by the incremental adjustments performed by adjtime(3) and NTP.
	Monotonic Clock = &clock{CLOCK_MONOTONIC}

	// High-resolution per-process timer from the CPU.
	Process Clock = &clock{CLOCK_PROCESS_CPUTIME_ID}
)

Available Clocks

type Timer

type Timer interface {

	// Elapsed returns the amount of time that has elapsed as measured
	// by the Timers underlying clock.
	Elapsed() time.Duration
}

A Timer represents an amount of time that elapsed according to a Clock.

var (
	// The amount of elapsed time since the bootup of this host.
	Uptime Timer = &timer{clock: clock{CLOCK_BOOTTIME}}
)

Available Timers

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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