Simplify MessageQueue pop() usage.

This commit is contained in:
Jared Boone 2015-08-27 14:35:17 -07:00
parent d8b3b4cb6b
commit b13081696d
3 changed files with 9 additions and 20 deletions

View File

@ -123,15 +123,9 @@ private:
}
void handle_application_queue() {
while(true) {
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
const Message* const message = reinterpret_cast<Message*>(message_buffer.data());
const auto message_size = shared_memory.application_queue.pop(message_buffer.data(), message_buffer.size());
if( message_size ) {
context.message_map.send(message);
} else {
break;
}
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
while(const Message* const message = shared_memory.application_queue.pop(message_buffer)) {
context.message_map.send(message);
}
}

View File

@ -242,15 +242,9 @@ private:
}
void handle_baseband_queue() {
while(true) {
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
const Message* const message = reinterpret_cast<Message*>(message_buffer.data());
const auto message_size = shared_memory.baseband_queue.pop(message_buffer.data(), message_buffer.size());
if( message_size ) {
message_map.send(message);
} else {
break;
}
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
while(const Message* const message = shared_memory.baseband_queue.pop(message_buffer)) {
message_map.send(message);
}
}

View File

@ -47,8 +47,9 @@ public:
return push(&message, sizeof(message));
}
size_t pop(void* const buf, const size_t len) {
return fifo.out_r(buf, len);
const Message* pop(std::array<uint8_t, Message::MAX_SIZE>& buf) {
const Message* const p = reinterpret_cast<Message*>(buf.data());
return fifo.out_r(buf.data(), buf.size()) ? p : nullptr;
}
size_t len() const {