prng

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveNextTimePoint

func ResolveNextTimePoint(nowSec int64, resolution int64) int64

ResolveNextTimePoint returns the next time point.

Types

type TimeSourceFunc

type TimeSourceFunc func() int64

TimeSourceFunc is a function which gets an understanding of time in seconds resolution back.

type UnixTimestampPrng

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

UnixTimestampPrng is a pseudo random number generator using the Unix time in seconds to derive a random number from.

func NewUnixTimestampPRNG

func NewUnixTimestampPRNG(resolution int64, timeSourceFunc ...TimeSourceFunc) *UnixTimestampPrng

NewUnixTimestampPRNG creates a new Unix timestamp based pseudo random number generator using the given resolution. The resolution defines at which second interval numbers are generated.

func (*UnixTimestampPrng) C

func (utrng *UnixTimestampPrng) C() <-chan float64

C returns the channel from which random generated numbers can be consumed from.

func (*UnixTimestampPrng) Start

func (utrng *UnixTimestampPrng) Start()

Start starts the Unix timestamp pseudo random number generator by examining the interval and then starting production of numbers after at least interval seconds plus delta of the next resolution time have elapsed.

func (*UnixTimestampPrng) Stop

func (utrng *UnixTimestampPrng) Stop()

Stop stops the Unix timestamp pseudo random number generator.

Jump to

Keyboard shortcuts

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