timer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Buckets = []float64{
		10,
		100,
		250,
		500,
		1000,
		1500,
		2000,
		3000,
		5000,
		10000,
	}
)

Useful latency buckets

Functions

This section is empty.

Types

type Clock

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

Clock acts as a thin wrapper around global time that allows for easy testing

func (*Clock) Set

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

Set the time on the clock

func (*Clock) Sync

func (c *Clock) Sync()

Sync this clock with global time

func (*Clock) Time

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

Time returns the time on this clock

func (*Clock) Unix

func (c *Clock) Unix() uint64

Unix returns the unix time on this clock.

type Executor

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

Executor ...

func (*Executor) Add

func (e *Executor) Add(event func())

Add new function to call

func (*Executor) Dispatch

func (e *Executor) Dispatch()

Dispatch the events. Will only return after stop is called.

func (*Executor) Initialize

func (e *Executor) Initialize()

Initialize ...

func (*Executor) Stop

func (e *Executor) Stop()

Stop executing functions

type Meter

type Meter interface {
	// Notify this meter of a new event for it to rate
	Tick()
	// Return the number of events this meter is currently tracking
	Ticks() int
}

Meter tracks the number of occurrences of a specified event

type Repeater

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

Repeater ...

func NewRepeater

func NewRepeater(handler func(), frequency time.Duration) *Repeater

NewRepeater ...

func (*Repeater) Dispatch

func (r *Repeater) Dispatch()

Dispatch ...

func (*Repeater) Stop

func (r *Repeater) Stop()

Stop ...

type TimedMeter

type TimedMeter struct {

	// Amount of time to keep a tick
	Duration time.Duration
	// contains filtered or unexported fields
}

TimedMeter is a meter that discards old events

func (*TimedMeter) Tick

func (tm *TimedMeter) Tick()

Tick implements the Meter interface

func (*TimedMeter) Ticks

func (tm *TimedMeter) Ticks() int

Ticks implements the Meter interface

type TimeoutManager

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

TimeoutManager is a manager for timeouts.

func (*TimeoutManager) Dispatch

func (tm *TimeoutManager) Dispatch()

Dispatch ...

func (*TimeoutManager) Initialize

func (tm *TimeoutManager) Initialize(duration time.Duration)

Initialize is a constructor b/c Golang, in its wisdom, doesn't ... have them?

func (*TimeoutManager) Put

func (tm *TimeoutManager) Put(id ids.ID, handler func())

Put puts hash into the hash map

func (*TimeoutManager) Remove

func (tm *TimeoutManager) Remove(id ids.ID)

Remove the item that no longer needs to be there.

func (*TimeoutManager) Stop

func (tm *TimeoutManager) Stop()

Stop executing timeouts

func (*TimeoutManager) Timeout

func (tm *TimeoutManager) Timeout()

Timeout registers a timeout

type Timer

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

Timer wraps a timer object. This allows a user to specify a handler. Once specifying the handler, the dispatch thread can be called. The dispatcher will only return after calling Stop. SetTimeoutIn will result in calling the handler in the specified amount of time.

func NewTimer

func NewTimer(handler func()) *Timer

NewTimer creates a new timer object

func (*Timer) Cancel

func (t *Timer) Cancel()

Cancel the currently scheduled event

func (*Timer) Dispatch

func (t *Timer) Dispatch()

Dispatch ...

func (*Timer) SetTimeoutIn

func (t *Timer) SetTimeoutIn(duration time.Duration)

SetTimeoutIn will set the timer to fire the handler in [duration]

func (*Timer) Stop

func (t *Timer) Stop()

Stop this timer from executing any more.

Jump to

Keyboard shortcuts

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