clock

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicTimestamp

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

AtomicTimestamp stores an atomic unix timestamp

func (*AtomicTimestamp) Load

func (a *AtomicTimestamp) Load() UnixTimestamp

Load the timestamp atomically

func (*AtomicTimestamp) Remaining

func (t *AtomicTimestamp) Remaining(lifetime time.Duration) time.Duration

Remaining time until expiration, considering the given lifetime

func (*AtomicTimestamp) Store

func (a *AtomicTimestamp) Store(v UnixTimestamp)

Store the timestamp atomically

func (*AtomicTimestamp) Tick

func (t *AtomicTimestamp) Tick(ctx context.Context, step time.Duration)

Tick updates the timestamp at periodic intervals

type Keeper

type Keeper struct {
	CancelCtx  context.Context
	CancelFunc context.CancelFunc
	Mutex      sync.Mutex
	Group      sync.WaitGroup
	// contains filtered or unexported fields
}

Keeper base struct for objects that need a cancellable ticker thread

func (*Keeper) Cancel

func (t *Keeper) Cancel()

Cancel the ticker and wait the group

func (*Keeper) Clock

func (t *Keeper) Clock() UnixTimestamp

Clock returns the current timestamp value

func (*Keeper) Tick

func (t *Keeper) Tick(step time.Duration)

Tick starts updating timestamp each time.Duration interval

type UnixTimestamp

type UnixTimestamp int64

UnixTimestamp defined to avoid having plain int64 type in APIs.

Jump to

Keyboard shortcuts

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