-
Notifications
You must be signed in to change notification settings - Fork 122
[1/?] Instant loop out: Add FSM module #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
hieblmi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, I really like the idea of having a common state machine template for future projects so reviewing new features becomes a lot easier in that respect. How did you arrive at choosing this particular one? Did you write it yourself or do we need to add a license disclaimer etc?
d8a6d52 to
d9cf3e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, PR is also almost ready imo. 🍔
fsm/fsm.go
Outdated
| Previous StateType | ||
|
|
||
| // Current represents the current state. | ||
| Current StateType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that SendEvent (and then getNextState) changes the Current's and Previous' value we might want to instead expose these as functions that also lock the mutex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mutex is locked for the whole duration of SendEvent. I opted to not export current and previous. It can now only be 'read' by a registeard observer
d9cf3e3 to
899b6a8
Compare
899b6a8 to
8bf6b3e
Compare
8bf6b3e to
4219658
Compare
bhandras
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few nits/questions remain from my end!
fsm/fsm.go
Outdated
| s.mutex.Lock() | ||
| defer s.mutex.Unlock() | ||
|
|
||
| fsmConfig := s.States |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do we need this local var?
4219658 to
94b31fa
Compare
bhandras
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost ready!
hieblmi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left some comments. Can't wait to use the FSM for new features.
94b31fa to
6cf159d
Compare
bhandras
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM FSM FTW 🥇
6cf159d to
6b79c1d
Compare
1230386 to
ef23fe2
Compare
bhandras
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
hieblmi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This commit adds a module for a finite state machine. The goal of the module is to provide a simple, easy to use, and easy to understand finite state machine. The module is designed to be used in future loop subsystems. Additionally a state visualizer is provided to help with understanding the state machine.
ef23fe2 to
20db07d
Compare
This PR adds a module for a finite state machine. The goal of the module is to provide a simple, easy to use, and easy to understand finite state machine. The module is designed to be used in future loop subsystems. Additionally a state visualizer is provided to help with understanding the state machine.
TODO
Next PR: #632