goer

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: ISC Imports: 7 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

This section is empty.

Types

type ClosingTicker

type ClosingTicker struct {
	C <-chan time.Time
	error116.ParlError
	// contains filtered or unexported fields
}

ClosingTicker is like time.Ticker but the channel C closes on shutdown. A closing channel is detectable by a listening thread

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) Shutdown

func (t *ClosingTicker) Shutdown()

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

type Goer

type Goer struct {
	T0     time.Time
	Number uint64
	// 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) 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 GoerStat

type GoerStat struct {
	ReceivedTicks uint64
	Launched      uint64
	Started       uint64
	Exited        uint64
	Panic         uint64
	Err           error
}

GoerStats contains the current execution state of managed threads

func (*GoerStat) String

func (gs *GoerStat) String() string

String produces a string representation of the currently running threads

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