From 379f42982b8c57ee6511cb8e498019f454323977 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 07 七月 2020 11:04:39 +0800 Subject: [PATCH] update --- squeue/include/SLinkedLockFreeQueue.h | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 deletions(-) diff --git a/squeue/include/SLinkedLockFreeQueue.h b/squeue/include/SLinkedLockFreeQueue.h index 66596f2..8225920 100644 --- a/squeue/include/SLinkedLockFreeQueue.h +++ b/squeue/include/SLinkedLockFreeQueue.h @@ -2,7 +2,7 @@ #ifndef SLinkedLockFreeQueue_H_ #define SLinkedLockFreeQueue_H_ #include "mm.h" -#include "pcsem.h" +#include "sem_util.h" #include "SAbstractQueue.h" @@ -102,8 +102,8 @@ Head.store(pointer, std::memory_order_relaxed); Tail.store(pointer, std::memory_order_relaxed); - slots = pcsem::init(IPC_PRIVATE, qsize); - items = pcsem::init(IPC_PRIVATE, 0); + slots = SemUtil::get(IPC_PRIVATE, qsize); + items = SemUtil::get(IPC_PRIVATE, 0); } @@ -111,8 +111,8 @@ SLinkedLockFreeQueue<T>::~SLinkedLockFreeQueue() { std::cerr << "SLinkedLockFreeQueue destory" << std::endl; - pcsem::remove(slots); - pcsem::remove(items); + SemUtil::remove(slots); + SemUtil::remove(items); Node<T> * nodeptr; @@ -189,12 +189,12 @@ template <typename T> bool SLinkedLockFreeQueue<T>::add(const T & item) { - if (pcsem::dec(slots) == -1) { + if (SemUtil::dec(slots) == -1) { err_exit(errno, "add"); } if (SLinkedLockFreeQueue<T>::_add(item)) { - pcsem::inc(items); + SemUtil::inc(items); return true; } return false; @@ -204,7 +204,7 @@ template <typename T> bool SLinkedLockFreeQueue<T>::add_nowait(const T & item) { - if (pcsem::dec_nowait(slots) == -1) { + if (SemUtil::dec_nowait(slots) == -1) { if (errno == EAGAIN) return false; else @@ -212,7 +212,7 @@ } if (SLinkedLockFreeQueue<T>::_add(item)) { - pcsem::inc(items); + SemUtil::inc(items); return true; } return false; @@ -222,7 +222,7 @@ template <typename T> bool SLinkedLockFreeQueue<T>::add_timeout(const T & item, struct timespec * timeout) { - if (pcsem::dec_timeout(slots, timeout) == -1) { + if (SemUtil::dec_timeout(slots, timeout) == -1) { if (errno == EAGAIN) return false; else @@ -230,7 +230,7 @@ } if (SLinkedLockFreeQueue<T>::_add(item)){ - pcsem::inc(items); + SemUtil::inc(items); return true; } return false; @@ -285,12 +285,12 @@ template <typename T> bool SLinkedLockFreeQueue<T>::remove(T & item) { - if (pcsem::dec(items) == -1) { + if (SemUtil::dec(items) == -1) { err_exit(errno, "remove"); } if (SLinkedLockFreeQueue<T>::_remove(item)) { - pcsem::inc(slots); + SemUtil::inc(slots); return true; } return false; @@ -300,7 +300,7 @@ template <typename T> bool SLinkedLockFreeQueue<T>::remove_nowait(T & item) { - if (pcsem::dec_nowait(items) == -1) { + if (SemUtil::dec_nowait(items) == -1) { if (errno == EAGAIN) return false; else @@ -308,7 +308,7 @@ } if (SLinkedLockFreeQueue<T>::_remove(item)) { - pcsem::inc(slots); + SemUtil::inc(slots); return true; } return false; @@ -318,7 +318,7 @@ template <typename T> bool SLinkedLockFreeQueue<T>::remove_timeout(T & item, struct timespec * timeout) { - if (pcsem::dec_timeout(items, timeout) == -1) { + if (SemUtil::dec_timeout(items, timeout) == -1) { if (errno == EAGAIN) return false; else @@ -326,7 +326,7 @@ } if (SLinkedLockFreeQueue<T>::_remove(item)) { - pcsem::inc(slots); + SemUtil::inc(slots); return true; } return false; -- Gitblit v1.8.0