/*************************************************************************
> File Name: lockfreequeue.cpp
> Author:
> Mail:
> Created Time: Wed 08 Aug 2018 11:38:08 AM CST
************************************************************************/
#include<iostream>
#include <atomic>
#include <memory>
#include <thread>
using namespace std;
template <class T>
class LockFreeQueue{
private:
struct CounterNode;
public:
LockFreeQueue(){
CounterNode node;
node.extern_counter_ = 1;
node.next_ = new Node();
tail_.store( node );
head_.store(node);
}
virtual ~LockFreeQueue(){}
void Push( T dta )
{
std::unique_ptr<T> dta_ptr(new T(dta));
CounterNode node;
node.extern_counter_ = 1;
node.next_= new Node();
CounterNode tail = tail_.load();
while(1)
{
c++11 无锁队列
最新推荐文章于 2024-05-23 17:22:21 发布