mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-12 15:59:49 -05:00
Simplify MessageQueue pop() usage.
This commit is contained in:
parent
d8b3b4cb6b
commit
b13081696d
@ -123,15 +123,9 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handle_application_queue() {
|
void handle_application_queue() {
|
||||||
while(true) {
|
|
||||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
||||||
const Message* const message = reinterpret_cast<Message*>(message_buffer.data());
|
while(const Message* const message = shared_memory.application_queue.pop(message_buffer)) {
|
||||||
const auto message_size = shared_memory.application_queue.pop(message_buffer.data(), message_buffer.size());
|
|
||||||
if( message_size ) {
|
|
||||||
context.message_map.send(message);
|
context.message_map.send(message);
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,15 +242,9 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handle_baseband_queue() {
|
void handle_baseband_queue() {
|
||||||
while(true) {
|
|
||||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
||||||
const Message* const message = reinterpret_cast<Message*>(message_buffer.data());
|
while(const Message* const message = shared_memory.baseband_queue.pop(message_buffer)) {
|
||||||
const auto message_size = shared_memory.baseband_queue.pop(message_buffer.data(), message_buffer.size());
|
|
||||||
if( message_size ) {
|
|
||||||
message_map.send(message);
|
message_map.send(message);
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,9 @@ public:
|
|||||||
return push(&message, sizeof(message));
|
return push(&message, sizeof(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pop(void* const buf, const size_t len) {
|
const Message* pop(std::array<uint8_t, Message::MAX_SIZE>& buf) {
|
||||||
return fifo.out_r(buf, len);
|
const Message* const p = reinterpret_cast<Message*>(buf.data());
|
||||||
|
return fifo.out_r(buf.data(), buf.size()) ? p : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len() const {
|
size_t len() const {
|
||||||
|
Loading…
Reference in New Issue
Block a user