From 21f03d8d05e5c04953e31d7e4360346031603511 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期四, 04 二月 2021 11:47:50 +0800
Subject: [PATCH] 修改注解
---
src/queue/lock_free_queue.h | 172 ++++++++++++++++++++++++++++----------------------------
1 files changed, 86 insertions(+), 86 deletions(-)
diff --git a/src/queue/lock_free_queue.h b/src/queue/lock_free_queue.h
index 70549d4..6554b9a 100644
--- a/src/queue/lock_free_queue.h
+++ b/src/queue/lock_free_queue.h
@@ -72,9 +72,9 @@
/// ArrayLockFreeQueue are supported (single producer
/// by default)
template<
- typename ELEM_T,
- typename Allocator = SHM_Allocator,
- template<typename T, typename AT> class Q_TYPE = ArrayLockFreeQueue
+ typename ELEM_T,
+ typename Allocator = SHM_Allocator,
+ template<typename T, typename AT> class Q_TYPE = ArrayLockFreeQueue
>
class LockFreeQueue {
@@ -148,160 +148,160 @@
template<
- typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename ELEM_T,
+ typename Allocator,
+ template<typename T, typename AT> class Q_TYPE>
LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::LockFreeQueue(size_t qsize): reference(0), 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)
- err_exit(errno, "LockFreeQueue sem_init");
- if (sem_init(&mutex, 1, 1) == -1)
- err_exit(errno, "LockFreeQueue sem_init");
+ // 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)
+ err_exit(errno, "LockFreeQueue sem_init");
+ if (sem_init(&mutex, 1, 1) == -1)
+ err_exit(errno, "LockFreeQueue sem_init");
}
template<
- typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename ELEM_T,
+ 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");
- }
- if (sem_destroy(&items) == -1) {
- err_exit(errno, "LockFreeQueue sem_destroy");
- }
- if (sem_destroy(&mutex) == -1) {
- err_exit(errno, "LockFreeQueue sem_destroy");
- }
+ // LoggerFactory::getLogger()->debug("LockFreeQueue desctroy");
+ if (sem_destroy(&slots) == -1) {
+ err_exit(errno, "LockFreeQueue sem_destroy");
+ }
+ if (sem_destroy(&items) == -1) {
+ err_exit(errno, "LockFreeQueue sem_destroy");
+ }
+ if (sem_destroy(&mutex) == -1) {
+ err_exit(errno, "LockFreeQueue sem_destroy");
+ }
}
template<
- typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename ELEM_T,
+ typename Allocator,
+ template<typename T, typename AT> class Q_TYPE>
inline uint32_t LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::size() {
- return m_qImpl.size();
+ return m_qImpl.size();
}
template<
- typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename ELEM_T,
+ typename Allocator,
+ template<typename T, typename AT> class Q_TYPE>
inline bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::full() {
- return m_qImpl.full();
+ return m_qImpl.full();
}
template<
- typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename ELEM_T,
+ typename Allocator,
+ template<typename T, typename AT> class Q_TYPE>
inline bool LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::empty() {
- return m_qImpl.empty();
+ return m_qImpl.empty();
}
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");
- 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) {
- goto LABEL_FAILTURE;
- }
+ if (psem_trywait(&slots) == -1) {
+ goto LABEL_FAILTURE;
+ }
} else if ((flag & BUS_TIMEOUT_FLAG) == BUS_TIMEOUT_FLAG && timeout != NULL) {
- if (psem_timedwait(&slots, timeout) == -1) {
- goto LABEL_FAILTURE;
- }
+ if (psem_timedwait(&slots, timeout) == -1) {
+ goto LABEL_FAILTURE;
+ }
} else {
- if (psem_wait(&slots) == -1) {
- goto LABEL_FAILTURE;
- }
+ if (psem_wait(&slots) == -1) {
+ goto LABEL_FAILTURE;
+ }
}
if (m_qImpl.push(a_data)) {
psem_post(&items);
- sigprocmask(SIG_SETMASK, &pre, NULL);
- LoggerFactory::getLogger()->debug("==================LockFreeQueue push after\n");
+ // sigprocmask(SIG_SETMASK, &pre, NULL);
+ // LoggerFactory::getLogger()->debug("==================LockFreeQueue push after\n");
return 0;
}
-
-LABEL_FAILTURE:
- sigprocmask(SIG_SETMASK, &pre, NULL);
+
+ LABEL_FAILTURE:
+ // sigprocmask(SIG_SETMASK, &pre, NULL);
return errno;
}
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>::pop(ELEM_T &a_data, const struct timespec *timeout, int flag) {
// LoggerFactory::getLogger()->debug("==================LockFreeQueue pop before....");
- 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) {
- goto LABEL_FAILTURE;
- }
+ if (psem_trywait(&items) == -1) {
+ goto LABEL_FAILTURE;
+ }
} 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) {
- goto LABEL_FAILTURE;
- }
+ if (psem_timedwait(&items, timeout) == -1) {
+ goto LABEL_FAILTURE;
+ }
} else {
- if (psem_wait(&items) == -1) {
- goto LABEL_FAILTURE;
- }
+ if (psem_wait(&items) == -1) {
+ goto LABEL_FAILTURE;
+ }
}
if (m_qImpl.pop(a_data)) {
- psem_post(&slots);
- sigprocmask(SIG_SETMASK, &pre, NULL);
- // LoggerFactory::getLogger()->debug("==================LockFreeQueue pop after\n");
- return 0;
+ psem_post(&slots);
+ // sigprocmask(SIG_SETMASK, &pre, NULL);
+ // LoggerFactory::getLogger()->debug("==================LockFreeQueue pop after\n");
+ return 0;
}
-LABEL_FAILTURE:
- sigprocmask(SIG_SETMASK, &pre, NULL);
+ LABEL_FAILTURE:
+ // sigprocmask(SIG_SETMASK, &pre, NULL);
return errno;
}
template<typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename Allocator,
+ template<typename T, typename AT> class Q_TYPE>
ELEM_T &LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::operator[](unsigned i) {
- return m_qImpl.operator[](i);
+ return m_qImpl.operator[](i);
}
template<typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename Allocator,
+ template<typename T, typename AT> class Q_TYPE>
void *LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::operator new(size_t size) {
- return Allocator::allocate(size);
+ return Allocator::allocate(size);
}
template<typename ELEM_T,
- typename Allocator,
- template<typename T, typename AT> class Q_TYPE>
+ typename Allocator,
+ template<typename T, typename AT> class Q_TYPE>
void LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::operator delete(void *p) {
- return Allocator::deallocate(p);
+ return Allocator::deallocate(p);
}
// include implementation files
--
Gitblit v1.8.0