lifecycle

package
v2.454.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func NewManager

func NewManager(initialState State) *Manager

func (*Manager) GetCurrentState

func (m *Manager) GetCurrentState() (state State)

GetCurrentState return the current state of the Manager

func (*Manager) TaskWaitForStateChange added in v2.441.0

func (m *Manager) TaskWaitForStateChange(ctx context.Context, sourceState State) (Task, bool)

TaskWaitForStateChange is the same as `WaitForStateChange` but also return a task that can be mark as done by the upper caller to notify he is done handling the new state, done should always be called to avoid deadlock. use `WaitForTasks` to wait for task to complete

func (*Manager) UpdateState

func (m *Manager) UpdateState(state State)

UpdateState update the current state of the Manager

func (*Manager) WaitForStateChange

func (m *Manager) WaitForStateChange(ctx context.Context, sourceState State) bool

WaitForStateChange waits until the currentState changes from sourceState or ctx expires. A true value is returned in former case and false in latter.

func (*Manager) WaitForTasks added in v2.441.0

func (m *Manager) WaitForTasks()

WaitForTasks wait until all tasks returned by `TaskWaitForStateChange` are done

type State

type State int
const (
	StateActive State = iota
	StateInactive
)

type Task added in v2.441.0

type Task interface {
	Done()
}

Jump to

Keyboard shortcuts

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