-
Notifications
You must be signed in to change notification settings - Fork 63
C++ example for playback over WebSocket #770
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
base: main
Are you sure you want to change the base?
Conversation
eloff
left a comment
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.
Again, just minor feedback
| // illustration, this example generates a fixed buffer of example data in-memory. | ||
| class DataPlayer { | ||
| public: | ||
| explicit DataPlayer(size_t num_timesteps, foxglove::RawChannel&& channel) |
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.
Don't think you need explicit here
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.
Good catch, this was left over from when the channel lived outside the class
|
|
||
| void process() { | ||
| if (!server_) { | ||
| throw std::runtime_error("Tried to spin with uninitialized server"); |
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.
Run or process might be better words than spin here
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 decided to use tick to show that this is being invoked by an outer execution loop
|
|
||
| // Internal variables for orchestrating playback. In addition to accessing data_, these are are | ||
| // used to generate a foxglove::PlaybackState to send to the Foxglove player. | ||
| std::atomic<size_t> current_playback_index_ = 0; |
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.
Using multiple atomics like this leads to all kinds of strange race conditions, seeing partial or out of order updates.
As an example I'd be more confortable if it was a mutex.
Maybe nothing bad happens here, but we should set a conservative example.
eloff
left a comment
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.
LGTM
0de50b9 to
4317d2a
Compare
Changelog
None
Docs
In-line documentation provided
Description
Annotated C++ example using the functionality introduced in #746.
Fixes: FLE-142