goer

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: ISC Imports: 16 Imported by: 0

Documentation

Overview

Package goer manages a large number of virtual threads

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatD added in v0.0.6

func FormatD(d time.Duration) (s string)

FormatD converts time.Duration to string with fewer digits

func Hostname added in v0.0.6

func Hostname() (hostname string)

func MemoryLinux added in v0.0.6

func MemoryLinux() (byts uint64)

func MemoryMacOS added in v0.0.6

func MemoryMacOS() (byts uint64)

func MemorySize added in v0.0.6

func MemorySize() (bytes uint64)

func MemorySizeString added in v0.0.6

func MemorySizeString() (s string)

func TsOut added in v0.0.6

func TsOut(T0 time.Time) (fn func(format string, a ...interface{}))

TsOut returns a printf logging function that prepends timestamp relative to T0

Types

type ClosingTicker

type ClosingTicker struct {
	C                  <-chan time.Time
	MaxDuration        time.Duration // atomic int64
	error116.ParlError               // panic in Shutdown or panic in tick thread
	// contains filtered or unexported fields
}

ClosingTicker is like time.Ticker but the channel C closes on shutdown. A closing channel is detectable by listening threads. If the computer is busy swapping, ticks will be lost. MaxDuration indicates the longest time observed between ticks. MaxDuration is normally 1 s

func NewClosingTicker

func NewClosingTicker(d time.Duration) (t *ClosingTicker)

NewClosingTicker returns a Ticker whose channel C closes on shutdown. A closing channel is detectable by a listening thread.

func (*ClosingTicker) GetError added in v0.0.6

func (t *ClosingTicker) GetError() (maxDuration time.Duration, err error)

func (*ClosingTicker) Shutdown

func (t *ClosingTicker) Shutdown()

Shutdown causes the channel C to close and resources to be released

type DataPoint added in v0.0.6

type DataPoint struct {
	Label      string
	IsNegative bool
	Value      uint64
}

func NewDataPoint added in v0.0.6

func NewDataPoint(label string, oldValue, newValue uint64) (d *DataPoint)

func (*DataPoint) IsSame added in v0.0.6

func (dp *DataPoint) IsSame() bool

func (*DataPoint) String added in v0.0.6

func (dp *DataPoint) String() string

type Goer

type Goer struct {
	T0                time.Time
	Number            uint64
	StatusThreadCount int

	error116.ParlError
	// contains filtered or unexported fields
}

Goer manages threads

func NewGoer

func NewGoer(threadCount uint64, tickPeriod time.Duration, fn func(goData *LaunchData), errCh chan<- error) (goer *Goer)

NewGoer launches a group of managed threads

func (*Goer) GetError added in v0.0.6

func (goer *Goer) GetError() (maxDuration time.Duration, err error)

func (*Goer) Shutdown

func (goer *Goer) Shutdown()

Shutdown shuts down all managed threads and the Goer instance

func (*Goer) Stats

func (goer *Goer) Stats() (gs *GoerStat)

Stats returns the current status of the managed threads

func (*Goer) String

func (goer *Goer) String() string

String produces a string representation of the currently running threads

func (*Goer) WaitLaunch

func (goer *Goer) WaitLaunch()

WaitLaunch wait untiul all threads have been launched

type GoerMax added in v0.0.6

type GoerMax struct {
	MaxDuration time.Duration
	MaxValue    uint64
	MaxRate     uint64
}

func (*GoerMax) CheckMax added in v0.0.6

func (gm *GoerMax) CheckMax(new uint64, old uint64, d time.Duration)

func (GoerMax) String added in v0.0.6

func (gm GoerMax) String() string

func (*GoerMax) Update added in v0.0.6

func (gm *GoerMax) Update(new *GoerStat, old *GoerStat)

type GoerStat

type GoerStat struct {
	T             time.Duration
	ReceivedTicks uint64
	Launched      uint64
	Started       uint64
	Exited        uint64
	Panic         uint64
	Err           error
}

GoerStats contains the current execution state of managed threads

func (*GoerStat) DiffString added in v0.0.6

func (gs *GoerStat) DiffString(prior *GoerStat) string

func (*GoerStat) Rate added in v0.0.6

func (gs *GoerStat) Rate(T time.Duration, newer, older uint64) string

func (*GoerStat) String

func (gs *GoerStat) String() string

String produces a string representation of the currently running threads

func (*GoerStat) StringState added in v0.0.6

func (gs *GoerStat) StringState() string

type LaunchData

type LaunchData struct {
	T0       time.Time
	ThreadID uint64
	Input    <-chan time.Time
	Output   chan<- time.Time
	Status   chan<- *ThreadUpdate
}

LaunchData is what a thread receives as launch parameter

type Status

type Status uint8
const (
	ThreadInvalid     Status = iota // bad: thread sent uninitialzied struct
	ThreadStart                     // thread has started reading its input channel
	ThreadInputClosed               // thread normal exit from input channel close
	ThreadPanic                     // thread terminated with panic
)

type ThreadUpdate

type ThreadUpdate struct {
	At       time.Duration
	ThreadID uint64
	Status   Status
	Count    uint64
	Recover  interface{}
}

ThreadUpdate is what a thread sends back on exit on the Status channel

Jump to

Keyboard shortcuts

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