lifecycle

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0, MIT Imports: 3 Imported by: 5

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

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

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

type Task interface {
	Done()
}

Jump to

Keyboard shortcuts

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