From 155d01b8c3bd34007c98898d86adef5adb5eded9 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Mon, 29 Oct 2018 18:10:07 +0100 Subject: [PATCH] Fix blocking=false for _pop & _get --- m-concurrent.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/m-concurrent.h b/m-concurrent.h index 3a6ec728..3418bdcc 100644 --- a/m-concurrent.h +++ b/m-concurrent.h @@ -341,13 +341,14 @@ { \ bool ret = false; \ m_mutex_lock (out->lock); \ - while (blocking) { \ + while (true) { \ M_GET_VALUE_TYPE oplist *p = M_CALL_GET_KEY(oplist, out->data, key); \ if (p != NULL) { \ M_CALL_SET(M_GET_VALUE_OPLIST oplist, *out_data, *p); \ ret = true; \ break; \ } \ + if (blocking == false) break; \ m_cond_wait(out->there_is_data, out->lock); \ } \ m_mutex_unlock (out->lock); \ @@ -361,12 +362,13 @@ { \ bool ret = false; \ m_mutex_lock (out->lock); \ - while (blocking) { \ + while (true) { \ if (!M_CALL_TEST_EMPTY(oplist, out->data)) { \ M_CALL_POP(oplist, p, out->data); \ ret = true; \ break; \ } \ + if (blocking == false) break; \ m_cond_wait(out->there_is_data, out->lock); \ } \ m_mutex_unlock (out->lock); \ @@ -380,12 +382,13 @@ { \ bool ret = false; \ m_mutex_lock (out->lock); \ - while (blocking) { \ + while (true) { \ if (!M_CALL_TEST_EMPTY(oplist, out->data)) { \ M_CALL_POP_MOVE(oplist, p, out->data); \ ret = true; \ break; \ } \ + if (blocking == false) break; \ m_cond_wait(out->there_is_data, out->lock); \ } \ m_mutex_unlock (out->lock); \