Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
/ fsm Public archive

A small and speedy finite state machine

License

Notifications You must be signed in to change notification settings

mixer/fsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fsm GoDoc Build Status

Why another FSM implementation? Because we didn't see one suited for smaller-scale, programmatic use in Go which was very efficient. Example use:

bp := fsm.New()
bp.Start(0)
bp.From(0).To(1)
bp.From(1).To(2).Then(func (m *fsm.Machine) { fmt.Println("hola!") })

m := bp.Machine()
m.State() // => a
m.Goto(1) // => error(nil)
m.State() // => b
m.Goto(2) // => error(nil)
// => hola!
m.Goto(1) // => error, "Transition 2 to 1 not permitted."

See the godocs for more information.

Benchmarks well, especially against comparable solutions.

➜  fsm git:(fsm) ✗ go test -bench=.
PASS
PASS
BenchmarkTransitions    100000000           20.8 ns/op
BenchmarkAllows          50000000           20.6 ns/op
BenchmarkGetState      2000000000           0.48 ns/op

About

A small and speedy finite state machine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages