-
Notifications
You must be signed in to change notification settings - Fork 59
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
Run client handler functions in separate thread #165
Conversation
: logTime(logTime) | ||
, publishTime(publishTime) | ||
, sequence(sequence) | ||
, advertisement(advertisement) | ||
, dataLength(dataLength) | ||
, data(data) {} | ||
, data(dataLength) { | ||
std::memcpy(data.data(), rawData, dataLength); |
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.
Is the additional copy worth it? We should test on a low-power platform like a Jetson Nano.
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.
We have to do a copy now since we call the handler in a different thread and the pointer to the original data is likely not valid anymore.
|
||
ClientMessage(uint64_t logTime, uint64_t publishTime, uint32_t sequence, | ||
const ClientAdvertisement& advertisement, size_t dataLength, const uint8_t* data) | ||
const ClientAdvertisement& advertisement, size_t dataLength, const uint8_t* rawData) | ||
: logTime(logTime) | ||
, publishTime(publishTime) | ||
, sequence(sequence) | ||
, advertisement(advertisement) |
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.
This is now a copy, but I'm assuming ClientAdvertisement
is relatively cheap to copy?
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 I think so too. At this stage I would rather have an extra copy then some hard to find bug. But yes, there is definitely potential for improvement later on
82c53b3
to
4d512fe
Compare
…210) ### Public-Facing Changes None ### Description - Refactors the way handler functions are run in a separate thread. It's better to do that in a unified way in the server rather than doing that for ROS 1 & 2 differently as it was implemented in #165 - Catch exeptions thrown in handler functions and send status message to client Fixes #148
Public-Facing Changes
Description
Builds on top of #156
So far we have executed client handler functions in the websocket server thread. This could cause issues with clients not receiving messages anymore while a longer-running handler function was executing. This PR fixes this by handler functions being executed in a separate thread.
Fixes #164
Fixes FG-2029