From 35f80491afb192b4d3bd564cd16d0d80190e92e9 Mon Sep 17 00:00:00 2001 From: deanlee Date: Thu, 4 Jul 2024 19:27:58 +0800 Subject: [PATCH] dd --- msgq/msgq.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/msgq/msgq.cc b/msgq/msgq.cc index f1bb269e..f8a60ad1 100644 --- a/msgq/msgq.cc +++ b/msgq/msgq.cc @@ -131,7 +131,6 @@ void msgq_close_queue(msgq_queue_t *q){ } } - void msgq_init_publisher(msgq_queue_t * q) { //std::cout << "Starting publisher" << std::endl; uint64_t uid = msgq_get_uid(); @@ -388,19 +387,16 @@ int msgq_msg_recv(msgq_msg_t * msg, msgq_queue_t * q){ goto start; } - return msg->size; } - - int msgq_poll(msgq_pollitem_t * items, size_t nitems, int timeout) { int num = 0; int timeout_ms = (timeout == -1) ? 100 : timeout; uint32_t last_futex_value = 0; auto start = std::chrono::high_resolution_clock::now(); - while (num == 0) { + while (true) { if (g_futex.wait(last_futex_value, timeout_ms)) { last_futex_value = g_futex.value(); @@ -415,6 +411,7 @@ int msgq_poll(msgq_pollitem_t * items, size_t nitems, int timeout) { break; } } + auto now = std::chrono::high_resolution_clock::now(); timeout_ms -= std::chrono::duration_cast(now - start).count(); if (timeout_ms <= 0) {