Use the right queue for each response type

This commit is contained in:
Andrea Cavalli 2020-08-31 17:42:43 +02:00
parent c04e7bcd47
commit 6e10e6f012

View File

@ -288,6 +288,7 @@ class TdReceiver {
std::atomic<bool> receive_lock_{false}; std::atomic<bool> receive_lock_{false};
MultiClient::Response receive_unlocked(double timeout, bool include_responses, bool include_updates) { MultiClient::Response receive_unlocked(double timeout, bool include_responses, bool include_updates) {
if (include_responses) {
if (output_responses_queue_ready_cnt_ == 0) { if (output_responses_queue_ready_cnt_ == 0) {
output_responses_queue_ready_cnt_ = output_responses_queue_->reader_wait_nonblock(); output_responses_queue_ready_cnt_ = output_responses_queue_->reader_wait_nonblock();
} }
@ -295,6 +296,8 @@ class TdReceiver {
output_responses_queue_ready_cnt_--; output_responses_queue_ready_cnt_--;
return output_responses_queue_->reader_get_unsafe(); return output_responses_queue_->reader_get_unsafe();
} }
}
if (include_updates) {
if (output_updates_queue_ready_cnt_ == 0) { if (output_updates_queue_ready_cnt_ == 0) {
output_updates_queue_ready_cnt_ = output_updates_queue_->reader_wait_nonblock(); output_updates_queue_ready_cnt_ = output_updates_queue_->reader_wait_nonblock();
} }
@ -302,6 +305,7 @@ class TdReceiver {
output_updates_queue_ready_cnt_--; output_updates_queue_ready_cnt_--;
return output_updates_queue_->reader_get_unsafe(); return output_updates_queue_->reader_get_unsafe();
} }
}
if (timeout != 0) { if (timeout != 0) {
if (include_responses && !include_updates) { if (include_responses && !include_updates) {
output_responses_queue_->reader_get_event_fd().wait(static_cast<int>(timeout * 1000)); output_responses_queue_->reader_get_event_fd().wait(static_cast<int>(timeout * 1000));