mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 08:07:37 +00:00
Methods to peek and skip messages in queue.
Allows receiver to not consume a message until after it's handled. And that enables the transmitter to block until the queue is empty, knowing that when unblocked, all messages in queue have been handled.
This commit is contained in:
@@ -114,6 +114,26 @@ public:
|
||||
return len;
|
||||
}
|
||||
|
||||
bool skip() {
|
||||
if( is_empty() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t len = peek_n();
|
||||
_out += len + recsize();
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t peek_r(void* const buf, size_t len) {
|
||||
if( is_empty() ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t n;
|
||||
len = out_copy_r((T*)buf, len, &n);
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t out_r(void* const buf, size_t len) {
|
||||
if( is_empty() ) {
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user