From c46be6db32872bfd7c4010b43526b5e6bc0fa6a5 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期一, 25 一月 2021 14:04:59 +0800
Subject: [PATCH] update

---
 src/queue/lock_free_queue.h |   87 +++++++++++++++++++++----------------------
 1 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/src/queue/lock_free_queue.h b/src/queue/lock_free_queue.h
index 9245d3e..723e373 100644
--- a/src/queue/lock_free_queue.h
+++ b/src/queue/lock_free_queue.h
@@ -207,31 +207,31 @@
 
 
 template<typename ELEM_T,
-        typename Allocator,
-        template<typename T, typename AT> class Q_TYPE>
+      typename Allocator,
+      template<typename T, typename AT> class Q_TYPE>
 int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push(const ELEM_T &a_data, const struct timespec *timeout, int flag) {
-    LoggerFactory::getLogger()->debug("==================LockFreeQueue push before\n");
-    if ((flag & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
-        if (psem_trywait(&slots) == -1) {
-            return -1;
-        }
-    } else if ((flag & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) {
-        if (psem_timedwait(&slots, timeout) == -1) {
-            return -1;
-        }
-    } else {
-        if (psem_wait(&slots) == -1) {
-            return -1;
-        }
-    }
+  LoggerFactory::getLogger()->debug("==================LockFreeQueue push before\n");
+  if ((flag & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
+      if (psem_trywait(&slots) == -1) {
+          return errno;
+      }
+  } else if ((flag & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) {
+      if (psem_timedwait(&slots, timeout) == -1) {
+          return errno;
+      }
+  } else {
+      if (psem_wait(&slots) == -1) {
+          return errno;
+      }
+  }
 
 
-    if (m_qImpl.push(a_data)) {
-        psem_post(&items);
-        LoggerFactory::getLogger()->debug("==================LockFreeQueue push after\n");
-        return 0;
-    }
-    return -1;
+  if (m_qImpl.push(a_data)) {
+    psem_post(&items);
+    LoggerFactory::getLogger()->debug("==================LockFreeQueue push after\n");
+    return 0;
+  }
+  return -1;
 
 }
 
@@ -239,31 +239,30 @@
         typename Allocator,
         template<typename T, typename AT> class Q_TYPE>
 int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::pop(ELEM_T &a_data, const struct timespec *timeout, int flag) {
+  LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before....");
 
-    LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before\n");
+  if ((flag & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
+      if (psem_trywait(&items) == -1) {
+          return errno;
+      }
+  } else if ((flag & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) {
+    LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before. flag=%d ,  %d\n", flag, timeout->tv_sec);
+      if (psem_timedwait(&items, timeout) == -1) {
+          return errno;
+      }
+  } else {
+      if (psem_wait(&items) == -1) {
+          return errno;
+      }
+  }
 
 
-    if ((flag & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
-        if (psem_trywait(&items) == -1) {
-            return -1;
-        }
-    } else if ((flag & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) {
-        if (psem_timedwait(&items, timeout) == -1) {
-            return -1;
-        }
-    } else {
-        if (psem_wait(&items) == -1) {
-            return -1;
-        }
-    }
-
-
-    if (m_qImpl.pop(a_data)) {
-        psem_post(&slots);
-        LoggerFactory::getLogger()->debug("==================LockFreeQueue pop after\n");
-        return 0;
-    }
-    return -1;
+  if (m_qImpl.pop(a_data)) {
+      psem_post(&slots);
+      LoggerFactory::getLogger()->debug("==================LockFreeQueue pop after\n");
+      return 0;
+  }
+  return -1;
 }
 
 template<typename ELEM_T,

--
Gitblit v1.8.0