mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
Hide most of MessageQueue functions.
This commit is contained in:
parent
bf348cf30a
commit
0fae1488c4
@ -60,6 +60,19 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename HandlerFn>
|
||||
void handle(HandlerFn handler) {
|
||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
||||
while(Message* const message = peek(message_buffer)) {
|
||||
handler(message);
|
||||
skip();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FIFO<uint8_t> fifo;
|
||||
Mutex mutex_write;
|
||||
|
||||
Message* peek(std::array<uint8_t, Message::MAX_SIZE>& buf) {
|
||||
Message* const p = reinterpret_cast<Message*>(buf.data());
|
||||
return fifo.peek_r(buf.data(), buf.size()) ? p : nullptr;
|
||||
@ -82,19 +95,6 @@ public:
|
||||
return fifo.is_empty();
|
||||
}
|
||||
|
||||
template<typename HandlerFn>
|
||||
void handle(HandlerFn handler) {
|
||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
||||
while(Message* const message = peek(message_buffer)) {
|
||||
handler(message);
|
||||
skip();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FIFO<uint8_t> fifo;
|
||||
Mutex mutex_write;
|
||||
|
||||
bool push(const void* const buf, const size_t len) {
|
||||
chMtxLock(&mutex_write);
|
||||
const auto result = fifo.in_r(buf, len);
|
||||
|
Loading…
Reference in New Issue
Block a user