-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add thread-safe way to interrupt waitForSubscriptionEvent(). #60
Add thread-safe way to interrupt waitForSubscriptionEvent(). #60
Conversation
Note: earliest I can test this is friday. I won't have access to a controller before then. |
Thanks for the PR 👍 . Unfortunately reviewing and merging it is going to take some time, as both me and @jontje have a very busy few weeks ahead of us. |
Understood. Testing has shown that However, |
Polite bump. Would a review be possible? By now I have tested this (manually) against a real IRC5 compact. It worked as intended during those tests. |
Thanks for the PR @de-vri-es, it's much appreciated 👍 My calendar has finally calmed down a bit, and I intend to review this and your other PRs this week. In the meanwhile, could you make sure your PRs are up-to-date with the base branch? |
Good to hear! I updated the branches. Note that they probably have merge conflicts with each-other (because of the commit in #58 that removed trailing whitespace). I can fix them when they appear :) |
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.
I have tested the implementation and it seems to be working as it should, and I have also added a few suggestions to the code. I.e.:
- Clarifications to some of the descriptions.
- Name change of closeSubscription to forceCloseSubscriotion.
- Curly brackets on new lines, to be consistent with the rest of the code base.
Please let me know if you dislike any of the changes.
* | ||
* This will cause waitForSubscriptionEvent() to return or throw. | ||
* It does not delete the subscription from the controller. | ||
* |
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.
* | |
* Preferred way to close the subscription is to request the robot controller to end it via endSubscription(). | |
* |
Just as a note that it is "nicer" for the robot controller to use endSubscription()
when possible.
Thanks for the review. I'll try to get round to processing the feedback on Friday. |
I think I processed the feedback. I added a slightly longer explanation that also includes when it is useful to call the new For now, I believe Either way, this function will still be useful if |
Thanks @de-vri-es 👍
Yes, I understand what you are getting at. Currently,
That is true 😄 |
This is an attempt to solve #59. It closes the socket in order to interrupt
p_websocket_->receiveFrame()
, and in turnwaitForSubscriptionEvent()
.A separate mutex is now used for setting
p_websocket_
and for using it. I believe this way there is no unnecessary blocking, but also no unsafe invalidation ofp_websocket_
.From my understanding, closing the socket before a full frame has been received will make
receiveFrame()
throw aWebSocketException
, which seems fine to me.