mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-26 22:37:13 -05:00
Move message handling loops to MessageQueue.
This commit is contained in:
parent
eb294c8e1c
commit
bf348cf30a
@ -134,10 +134,9 @@ void EventDispatcher::dispatch(const eventmask_t events) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::handle_application_queue() {
|
void EventDispatcher::handle_application_queue() {
|
||||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
shared_memory.application_queue.handle([](Message* const message) {
|
||||||
while(Message* const message = shared_memory.application_queue.pop(message_buffer)) {
|
|
||||||
message_map().send(message);
|
message_map().send(message);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::handle_rtc_tick() {
|
void EventDispatcher::handle_rtc_tick() {
|
||||||
|
@ -86,11 +86,9 @@ void EventDispatcher::dispatch(const eventmask_t events) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::handle_baseband_queue() {
|
void EventDispatcher::handle_baseband_queue() {
|
||||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
shared_memory.baseband_queue.handle([this](Message* const message) {
|
||||||
while(Message* const message = shared_memory.baseband_queue.peek(message_buffer)) {
|
this->on_message(message);
|
||||||
on_message(message);
|
});
|
||||||
shared_memory.baseband_queue.skip();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::on_message(const Message* const message) {
|
void EventDispatcher::on_message(const Message* const message) {
|
||||||
|
@ -82,6 +82,15 @@ public:
|
|||||||
return fifo.is_empty();
|
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:
|
private:
|
||||||
FIFO<uint8_t> fifo;
|
FIFO<uint8_t> fifo;
|
||||||
Mutex mutex_write;
|
Mutex mutex_write;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user