C++11 多线程高性能库ConcurrentQueue(多生产者、多消费者)

本文介绍了C++11的一个高效多生产者、多消费者无锁并发队列库ConcurrentQueue。这是一个仅包含头文件的库,提供了一种快速的线程安全数据通信方式。通过GitHub链接提供了源码获取途径,并详细阐述了其使用方法,包括基本API、内存管理、阻塞操作、Token使用和批处理Bulk操作。
摘要由CSDN通过智能技术生成

#1.简介
ConcurrentQueue是一个header only多线程库

A fast multi-producer, multi-consumer lock-free concurrent queue for C++11

Github地址:https://github.com/cameron314/concurrentqueue


#2.使用方法
>1.将以下2个文件复制到项目目录即可使用
concurrentqueue.h
blockingconcurrentqueue.h

>2.代码使用

#include "concurrentqueue.h"
#include "blockingconcurrentqueue.h"

using namespace std;
using namespace moodycamel;


#. 全部Api,伪代码

# Allocates more memory if necessary
enqueue(item) : bool
enqueue(prod_token, item) : bool
enqueue_bulk(item_first, count) : bool
enqueue_bulk(prod_token, item_first, count) : bool

# Fails if not enough memory to enqueue
try_enqueue(item) : bool
try_enqueue(prod_token, item) : bool
try_enqueue_bulk(item_first, count) : bool
try_enqueue_bulk(prod_token
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值