Skip to content

Conversation

@ericmlujan
Copy link
Contributor

Changelog

None

Docs

In-line documentation provided

Description

Annotated C++ example using the functionality introduced in #746.

Fixes: FLE-142

@linear
Copy link

linear bot commented Nov 19, 2025

Copy link
Contributor

@eloff eloff left a 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)
Copy link
Contributor

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

Copy link
Contributor Author

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");
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor

@eloff eloff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from eric/fle-124-c-bindings-for-playerstate-callbacks to main November 20, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants