From 6e0dc69afa4c7171f9e31a50ad20d561189f7346 Mon Sep 17 00:00:00 2001
From: fujuntang <fujuntang@smartai.com>
Date: 星期二, 31 八月 2021 17:44:55 +0800
Subject: [PATCH] Merge branch 'master' of http://os.smartai.com:9091/valib/c_bhomebus
---
src/queue/lock_free_queue.h | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/queue/lock_free_queue.h b/src/queue/lock_free_queue.h
index f536208..ada70c6 100644
--- a/src/queue/lock_free_queue.h
+++ b/src/queue/lock_free_queue.h
@@ -15,7 +15,7 @@
#include "bus_def.h"
// default Queue size
-#define LOCK_FREE_Q_DEFAULT_SIZE 16
+#define LOCK_FREE_Q_DEFAULT_SIZE 320
#define LOCK_FREE_Q_ST_OPENED 0
@@ -177,6 +177,7 @@
typename Allocator,
template<typename T, typename AT> class Q_TYPE>
LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::LockFreeQueue(size_t qsize): m_qImpl(qsize) {
+ //std::cout << "LockFreeQueue init reference=" << reference << std::endl;
if (sem_init(&slots, 1, qsize) == -1)
err_exit(errno, "LockFreeQueue sem_init");
if (sem_init(&items, 1, 0) == -1)
@@ -211,6 +212,7 @@
typename Allocator,
template<typename T, typename AT> class Q_TYPE>
LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::~LockFreeQueue() {
+ // LoggerFactory::getLogger()->debug("LockFreeQueue desctroy");
if (sem_destroy(&slots) == -1) {
err_exit(errno, "LockFreeQueue sem_destroy");
}
@@ -249,10 +251,10 @@
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) {
- // sigset_t mask_all, pre;
- // sigfillset(&mask_all);
+ sigset_t mask_all, pre;
+ sigfillset(&mask_all);
- // sigprocmask(SIG_BLOCK, &mask_all, &pre);
+ sigprocmask(SIG_BLOCK, &mask_all, &pre);
if ((flag & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
if (psem_trywait(&slots) == -1) {
@@ -271,12 +273,12 @@
if (m_qImpl.push(a_data)) {
psem_post(&items);
- // sigprocmask(SIG_SETMASK, &pre, NULL);
+ sigprocmask(SIG_SETMASK, &pre, NULL);
return 0;
}
LABEL_FAILTURE:
- // sigprocmask(SIG_SETMASK, &pre, NULL);
+ sigprocmask(SIG_SETMASK, &pre, NULL);
return errno;
}
@@ -285,10 +287,10 @@
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) {
- // sigset_t mask_all, pre;
- // sigfillset(&mask_all);
+ sigset_t mask_all, pre;
+ sigfillset(&mask_all);
- // sigprocmask(SIG_BLOCK, &mask_all, &pre);
+ sigprocmask(SIG_BLOCK, &mask_all, &pre);
if ((flag & BUS_NOWAIT_FLAG) == BUS_NOWAIT_FLAG) {
if (psem_trywait(&items) == -1) {
@@ -306,13 +308,13 @@
if (m_qImpl.pop(a_data)) {
psem_post(&slots);
- // sigprocmask(SIG_SETMASK, &pre, NULL);
+ sigprocmask(SIG_SETMASK, &pre, NULL);
return 0;
}
LABEL_FAILTURE:
- // sigprocmask(SIG_SETMASK, &pre, NULL);
+ sigprocmask(SIG_SETMASK, &pre, NULL);
return errno;
}
--
Gitblit v1.8.0