Skip to content
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

ofThreadChannel::clear() to clear the channel #7921

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions libs/openFrameworks/utils/ofThreadChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ class ofThreadChannel{
condition.notify_all();
}

/// \brief Clear channel.
///
/// Clears the queue (useful if only the latest
/// data is meant to be transferred (i.e. no queue))
void clear() {
if (!queue.empty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

.empty()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah wow!

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

std::unique_lock<std::mutex> lock(mutex);
queue = {};
}
}

/// \brief Queries empty channel.
///
Expand Down