Skip to content
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

Is it one redundant code? #41

Open
falconray0704 opened this issue Mar 19, 2019 · 0 comments
Open

Is it one redundant code? #41

falconray0704 opened this issue Mar 19, 2019 · 0 comments
Labels

Comments

@falconray0704
Copy link

falconray0704 commented Mar 19, 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.

@falconray0704 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants