-
Notifications
You must be signed in to change notification settings - Fork 96
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
Fix race condition with preemption timers #307
Conversation
f3cd970
to
09fc238
Compare
09fc238
to
9eb2328
Compare
Is |
@@ -50,7 +50,7 @@ BoostVM::BoostVM(BoostEnvironment& environment, | |||
uuidGenerator(), | |||
portClosed(false), | |||
_asyncIONodeCount(0), | |||
preemptionTimer(environment.io_service), | |||
preemptionTimer(nullptr), | |||
alarmTimer(environment.io_service), |
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.
What about this timer? Is it only accessed through this VM's thread?
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.
Yes. It would be simpler to do the same for preemptionTimer, but then it would not be able to restart itself, and the restart should be done in the vm when the preemption flag is cleared. And it looks difficult because the vm is a real vm, while the other is a boostvm...
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.
And it looks difficult because the vm is a real vm, while the other is a boostvm...
I think that just need adding one method in the interface between the two, but I don't remember the details. It would change semantics from "preempt every millisecond" to "preempt every millisecond+the time for VM to notice" though.
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.
Exactly. And this works, so why bother ;-)
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.
Nice work!
It looks good to me, but I am no Boost AsyncIO expert.
Fixes #305 and closes #284.
/cc @sjrd, @eregon Would you mind reviewing this ?