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

Does SyncExecutor assumed to have a concurrent access #7

Closed
mrniko opened this issue May 27, 2013 · 4 comments
Closed

Does SyncExecutor assumed to have a concurrent access #7

mrniko opened this issue May 27, 2013 · 4 comments

Comments

@mrniko
Copy link

mrniko commented May 27, 2013

SyncExecutor seems to be implemented in a thread-safe manner. Right?

@Beh01der
Copy link
Owner

Correct.
Both sync and async executors are single-threaded and run tasks consequentially (next task starts only when current is completed). Thus, for logic, implemented within state / event handlers there is no concurrency.

@mrniko
Copy link
Author

mrniko commented May 28, 2013

If it thread-safe why you need to use queue in SyncExecutor?

@Beh01der
Copy link
Owner

I wanted to isolate task execution.

Let's say we have handler for state State and in that handler we trigger event Event that moves FSM into state State2 that also has a handler.
If tasks are not separated, then execution flow will enter handler for State, then, when Event triggered execution flow will get into handler for State2, then it will return back to handler for State (if there is some code after trigger() call). To avoid it, I used queue.

With the queue, first, handler for State will be fully executed, and then, if event was triggered, handler for State2.

Also, SyncExecutor was ment mainly for unit tests, to avoid thread creation / waiting / termination but at the same time behave the same way as AsyncExecutor does.

@mrniko
Copy link
Author

mrniko commented Jun 3, 2013

Ok, i was wrong.

@mrniko mrniko closed this as completed Jun 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants