Skip to content

Commit 62feca7

Browse files
authored
ofThreadChannel::clear() to clear the channel (#7921) #changelog #threadChannel
* ofThreadChannel::clear() to clear the channel * fix empty to empty()
1 parent 1f62174 commit 62feca7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

libs/openFrameworks/utils/ofThreadChannel.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ class ofThreadChannel{
266266
condition.notify_all();
267267
}
268268

269+
/// \brief Clear channel.
270+
///
271+
/// Clears the queue (useful if only the latest
272+
/// data is meant to be transferred (i.e. no queue))
273+
void clear() {
274+
if (!queue.empty()) {
275+
std::unique_lock<std::mutex> lock(mutex);
276+
queue = {};
277+
}
278+
}
269279

270280
/// \brief Queries empty channel.
271281
///

0 commit comments

Comments
 (0)