Check queue empty only once when reading messages.

There was a second is_empty() call hidden in the pop() call, so the while(condition) was redundant.
This commit is contained in:
Jared Boone 2015-08-27 14:27:29 -07:00
parent 5d9079f87f
commit d8b3b4cb6b
2 changed files with 6 additions and 2 deletions

View File

@ -123,12 +123,14 @@ private:
}
void handle_application_queue() {
while( !shared_memory.application_queue.is_empty() ) {
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;
}
}
}

View File

@ -242,12 +242,14 @@ private:
}
void handle_baseband_queue() {
while( !shared_memory.baseband_queue.is_empty() ) {
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;
}
}
}