state

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State string
const (
	// livecycle States of a thread
	Reserved      State = "reserved"
	Booting       State = "booting"
	BootRequested State = "boot requested"
	ShuttingDown  State = "shutting down"
	Done          State = "done"

	// these States are 'stable' and safe to transition from at any time
	Inactive State = "inactive"
	Ready    State = "ready"

	// States necessary for restarting workers
	Restarting State = "restarting"
	Yielding   State = "yielding"

	// States necessary for transitioning between different handlers
	TransitionRequested  State = "transition requested"
	TransitionInProgress State = "transition in progress"
	TransitionComplete   State = "transition complete"
)

type ThreadState

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

func NewThreadState

func NewThreadState() *ThreadState

func (*ThreadState) CompareAndSwap

func (ts *ThreadState) CompareAndSwap(compareTo State, swapTo State) bool

func (*ThreadState) Get

func (ts *ThreadState) Get() State

func (*ThreadState) Is

func (ts *ThreadState) Is(state State) bool

func (*ThreadState) IsInWaitingState

func (ts *ThreadState) IsInWaitingState() bool

IsInWaitingState returns true if a thread is waiting for a request or shutdown

func (*ThreadState) MarkAsWaiting

func (ts *ThreadState) MarkAsWaiting(isWaiting bool)

MarkAsWaiting hints that the thread reached a stable state and is waiting for requests or shutdown

func (*ThreadState) Name

func (ts *ThreadState) Name() string

func (*ThreadState) RequestSafeStateChange

func (ts *ThreadState) RequestSafeStateChange(nextState State) bool

safely request a state change from a different goroutine

func (*ThreadState) Set

func (ts *ThreadState) Set(nextState State)

func (*ThreadState) SetWaitTime

func (ts *ThreadState) SetWaitTime(t time.Time)

func (*ThreadState) WaitFor

func (ts *ThreadState) WaitFor(states ...State)

block until the thread reaches a certain state

func (*ThreadState) WaitTime

func (ts *ThreadState) WaitTime() int64

WaitTime returns the time since the thread is waiting in a stable state in ms

Jump to

Keyboard shortcuts

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