From 37a7bd95042c19d7334b099d50ac6dc8e07e4b4e Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期二, 07 七月 2020 16:40:51 +0800
Subject: [PATCH] update

---
 squeue/include/linked_lock_free_queue.h |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/squeue/include/linked_lock_free_queue.h b/squeue/include/linked_lock_free_queue.h
index 58cdc00..f1aaf98 100644
--- a/squeue/include/linked_lock_free_queue.h
+++ b/squeue/include/linked_lock_free_queue.h
@@ -47,17 +47,21 @@
 
 
 
-template <typename T>
+template <typename ELEM_T>
 class LinkedLockFreeQueue
 {
+
+    template <
+        typename ELEM_T_, 
+        template <typename T> class Q_TYPE >
+    friend class LockFreeQueue;
 private:
 // class scope definitions
     enum {Q_SIZE = 10};
-    
   
 // private class members
-    std::atomic<Pointer<T> > Head;       // pointer to front of Queue
-    std::atomic<Pointer<T> > Tail;        // pointer to rear of Queue
+    std::atomic<Pointer<ELEM_T> > Head;       // pointer to front of Queue
+    std::atomic<Pointer<ELEM_T> > Tail;        // pointer to rear of Queue
     //std::atomic_uint count;          // current number of size in Queue
     std::atomic_uint count;
     const size_t qsize;    // maximum number of size in Queue
@@ -70,15 +74,13 @@
     bool empty() const;
     bool full() const;
     unsigned int size() const;
-    bool push(const T &item); // add item to end
-    bool pop(T &item);
+    bool push(const ELEM_T &item); // add item to end
+    bool pop(ELEM_T &item);
     
 
-    T& operator[](unsigned i);
+    ELEM_T& operator[](unsigned i);
 
 };
-
-
 
 
 // Queue methods
@@ -91,15 +93,12 @@
     Head.store(pointer, std::memory_order_relaxed);
     Tail.store(pointer, std::memory_order_relaxed);
 
- 
-   
 }
 
 template <typename T>
 LinkedLockFreeQueue<T>::~LinkedLockFreeQueue()
 {
     std::cerr << "LinkedLockFreeQueue destory" << std::endl;
-    
     Node<T> * nodeptr;
     Pointer<T> tmp = Head.load(std::memory_order_relaxed);
     while((nodeptr = tmp.ptr) != NULL) {
@@ -108,7 +107,6 @@
         delete nodeptr;
 
     }
-    
 }
 
 template <typename T>

--
Gitblit v1.8.0