time

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2019 License: Apache-2.0 Imports: 2 Imported by: ? 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 time contains some generic tools and helpers that are missing from the go's standard library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Refresher

type Refresher interface {
	// StartRefreshing() starts asynchronous periodic refresh of interfaces and
	// assigned IPs from the operating system
	StartRefreshing()

	// StopRefreshing() stops asynchronous periodic refresh of interfaces and
	// assigned IPs from the operating system
	StopRefreshing()

	// GetRefreshCount() returns how many times was the interfaces information
	// reloaded
	GetRefreshCount() int

	// IsRefreshing() returns true if currently the Refresher is Started
	// and running action
	IsRefreshing() bool
}

Refresher is a general thread safe periodic job runner with Start/Stop methods.

func NewRefresher

func NewRefresher(channel <-chan time.Time, action func(), refreshOnCreate, autoRefresh bool) Refresher

NewRefresher returns a new thread safe refresher, which runs action() if only it was previously Started. action() is run every time there's a new message in channel. Messages from channel are received in sequence.

func NewTickerRefresher

func NewTickerRefresher(action func(), refreshOnCreate, autoRefresh bool, autoRefreshPeriod time.Duration) Refresher

NewTickerRefresher returns a Refresher where refresh events are generated by a timed channel created with time.Ticker. It means, that if action() takes longer than refreshPeriod, refresh messages will be queued in the channel and a new action() will start immediately after the previous one ends.

Jump to

Keyboard shortcuts

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