You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Firstly, thanks for you work, it's a great job.
I have one question in the following code:
*In fsm.go line:324 function: func (f FSM) Event(event string, args ...interface{}) error
// Perform the rest of the transition, if not asynchronous.
f.stateMu.RUnlock()
err = f.doTransition()
f.stateMu.RLock()
if err != nil {
return InternalError{}
}
Per the comment in line:319 "// Perform the rest of the transition, if not asynchronous.".
I think that means in sync mode would run the following code.
So, InternalError{} should come from f.doTransition()
Then transitionerStruct's transition() should be called.
But In this function, the only way return error is "f.transition == nil" func (t transitionerStruct) transition(f *FSM) error {
if f.transition == nil {
return NotInTransitionError{}
}
f.transition()
f.transition = nil
return nil
}
But, per the previous code, if "f.doTransition()" can be invoked, "f.transition" have no way to get nil.
Is it one redundant code? I'm confuse, I hope I could get your help to confirm did I miss something or not.
The text was updated successfully, but these errors were encountered:
falconray0704
changed the title
May I get your help? I can not find the way get into InternalError{} in fsm.go line:324
Is it one redundant code?
Apr 2, 2019
Hi,
Firstly, thanks for you work, it's a great job.
I have one question in the following code:
*In fsm.go line:324 function: func (f FSM) Event(event string, args ...interface{}) error
// Perform the rest of the transition, if not asynchronous.
f.stateMu.RUnlock()
err = f.doTransition()
f.stateMu.RLock()
if err != nil {
return InternalError{}
}
Per the comment in line:319 "// Perform the rest of the transition, if not asynchronous.".
I think that means in sync mode would run the following code.
So, InternalError{} should come from f.doTransition()
But, In function:
// doTransition wraps transitioner.transition.
func (f *FSM) doTransition() error {
return f.transitionerObj.transition(f)
}
"f.transitionerObj" is "transitionerStruct"
Then transitionerStruct's transition() should be called.
But In this function, the only way return error is "f.transition == nil"
func (t transitionerStruct) transition(f *FSM) error {
if f.transition == nil {
return NotInTransitionError{}
}
f.transition()
f.transition = nil
return nil
}
But, per the previous code, if "f.doTransition()" can be invoked, "f.transition" have no way to get nil.
Is it one redundant code? I'm confuse, I hope I could get your help to confirm did I miss something or not.
The text was updated successfully, but these errors were encountered: