randgen

package
v0.0.0-...-e31961d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator for number generation in go is not concurrently safe (for new source). In order to generate random number concurrently, a number of workers to generate the random numbers are needed. each worker will generate a random number and push it into a buffered channel Reference: https://golang.org/pkg/math/rand/

func New

func New(workernumber, min, max int, seed int64) *Generator

New random number generator

func (*Generator) Generate

func (gen *Generator) Generate() int

Generate a new random number

func (*Generator) Stop

func (gen *Generator) Stop()

Stop generator's worker

type RandWorker

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

RandWorker struct

func (*RandWorker) Work

func (rw *RandWorker) Work()

Work via goroutines the worker will run forever when program runs but will get destroyed if the program exit

Jump to

Keyboard shortcuts

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