fsm

package
v1.1.18 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: GPL-3.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSM

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

状态机

func New

func New() *FSM

创建一个状态机

func (*FSM) Add

func (s *FSM) Add(state StateHandler) error

新增一个状态

func (*FSM) CurrentStateHandler

func (s *FSM) CurrentStateHandler() StateHandler

当前状态对象

func (*FSM) ForceState

func (s *FSM) ForceState(state int)

设置状态

func (*FSM) Handle

func (s *FSM) Handle(v interface{})

func (*FSM) State

func (s *FSM) State() int

当前状态

func (*FSM) Switch

func (s *FSM) Switch(next_state int) error

状态迁移

type StateHandler

type StateHandler interface {
	State() int
	Enter(*FSM)
	Leave(*FSM)
	Handle(*FSM, interface{})
}

状态对象

Jump to

Keyboard shortcuts

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