C++ 生产者消费者

C++ 实现多线程:生产者消费者模型 C++ 实现多线程:生产者消费者模型 #include <iostream> #include <mutex> #include <thread> #ifdef _MSC_VER #include <windows.h> // windows #else #include <unistd.h> // linux #endif // ... 阅读详情

当前C++11已经实现了多线程、互斥量、条件变量等异步处理函数,并且提供了诸如sleep之类的时间函数,所以后面使用C++开发这一块的时候完全可以实现跨平台,无需在windows下写一套然后又在linux下写一套了。

   本文用C++11实现了一个简单的生产者-消费者模式,生产者每1S将一个数值放到双向队列中,消费者每2S从双向队列中取出数据。

#ifndef SEMAPHORE_H
#define SEMAPHORE_H
#include <iostream>
#include <mutex>
#include <deque>
#include <thread>
#include <vector>
#include <condition_variable>
using namespace std;

class semaphore{
    public:
        semaphore(){
            _data.clear();
            count = 0;
        }
        void start(int product_num,int consume_num){
             vector<thread> threads;
             threads.clear();
             for(int index = 0;index < product_num;index++){
                threads.push_back(std::thread(&semaphore::product_thread,this));
             }
             for(int index = product_num;index < product_num + consume_num;index++){
                threads.push_back(std::thread(&semaphore::consume_thread,this));
             }

             for(auto& t:threads){
                t.detach();
             }
        }
    private:
        void product_thread(){
                while(true){
                    {
                        unique_lock<mutex> lck(_mutex);
                        if(_data.size() > 10){
                            cv.wait(lck);
                        }else{
                            cout<<"current product thread:"<<this_thread::get_id()<<" product "<<count<<endl;
                            count++;
                            count = count%10;
                            _data.push_back(count);
                            cv.notify_all();
                        }
                    }
                    chrono::milliseconds dura(1000);
			        this_thread::sleep_for(dura);
                }
        }        
        void consume_thread(){
                while(true){
                    {
                        unique_lock<mutex> lck(_mutex);
                        if(_data.empty()){
                            cv.wait(lck);
                        }else{
                            cout<<"current consume thread:"<<this_thread::get_id()<<" consume "<<_data.front()<<endl;
                            _data.pop_front();
                        }
                    }
                    chrono::milliseconds dura(2000);
                    this_thread::sleep_for(dura);
                }
        }
    private:
        int count;
        deque<int> _data;
        mutex _mutex;
        condition_variable cv; 
};
#endif  //SEMPHORE_H

转载:https://blog.youkuaiyun.com/dailongjian2008/article/details/53184706

代码下载:https://github.com/NearLife/WhatYouThinking.git

C++11多线程实现生产者消费者 生产者消费者 生产者消费者是典型的多线程模型。 单生产者-单消费者 #include <iostream> #include <mutex> #include <condition_variable> #include <queue> using namespace std; class Queue { public: void put(int val) { // lock_guard<mutex> lock(mtx); uniqu 阅读详情

相关推荐

生产者消费者 C++

生产者消费者思路: 首先定义一个缓冲区Buffer,当Buffer的大小小于BUFFERSIZE,则让生产者一直往里填充数据,满了后则让消费者开始往外拿数据,这里我们可以利用多线程中的Semaphore信号量同步机制,生产者初始化地最多的线程数为4个,这样当调用Waitforsingleproject(g_empty,INIFINITE);这样当我们每次调用一次这个函数,g_empty的引用计数

飞翔在北京的博客 527

【C++】【设计模式之】生产者-消费者模型(理论讲解及实现)

一、什么是生产者-消费者模型 1、简单理解生产者-消费者模型 假设有两个进程(或线程)A、B和一个固定大小的缓冲区,A进程生产数据放入缓冲区,B进程从缓冲区中取出数据进行计算,这就是一个简单的生产者-消费者模型。这里的A进程相当于生产者,B进程相当于消费者。 2、为什么要使用生产者-消费者模型 在多线程开发中,如果生产者生产数据的速度很快,而消费者消费数据的速度很慢,那么生产者就必须等待消费者消费完数据才能够继续生产数据,因为生产过多的数据可能会导致存储不足;同理如果消费者的速度大于生产者那么消费者就会经常

格物致知 1万+

生产者-消费者问题(C++信号量实现)

生产者-消费者问题是很经典的线程同步问题,这段代码给出的是多生产者、多消费者、有界缓冲区的一个C++实现。 常见的生产者消费者实现一般是Unix或Linux下的使用Pthread完成的,这里使用WINDOWS环境下的API实现。 #include<iostream> #include<queue> #include<Windows.h> #include<...

lxx909546478的博客 4417

C++ 生产者-消费者模式详细解析与代码实现

生产者-消费者模式是一种通过缓冲区将生产者和消费者解耦的设计模式。生产者线程负责生成数据,而消费者线程负责消费数据。由于生产者和消费者的工作速度可能不同,因此缓冲区的存在使得它们可以独立运行。生产者-消费者模式是一种常见且有效的并发编程模型。在C++中,通过std::mutex和,我们可以轻松实现这一模式来协调多线程间的工作。本篇博客详细介绍了该模式的工作原理,并通过代码示例展示了它的实现。希望对你理解并应用生产者-消费者模式有所帮助。

shuai_258的博客 7586

生产者 消费者 模式 c++

生产者 消费者 模式 c++ 算是老外写的一个使用demo 可以参考一下

Matlab激活失败?手把手教你解决License checkout failed问题(附详细截图)

本文针对Matlab激活后出现“License checkout failed”错误的常见问题,提供了详细的解决方案。核心在于精准定位并正确填写Windows系统用户名,而非计算机名或账户全名。文章通过分步截图和命令指引,手把手教你使用`whoami`命令获取正确信息,并重新运行激活程序,从根本上解决因用户名填写错误导致的许可检查失败问题。

weixin_29062823的博客 576

用C++实现生产者-消费者问题模型

用C++来实现生产者与消费者的模型,同时稍微讲解一点可能要讲解的地方。

qq_35160090的博客 1万+

VMvare 桥接模式无法联网、没有未桥接的主机网络适配器,无法将网络更改为桥接状态。

很多程序员,整天沉浸在业务代码的 CRUD 中,业务中没有大量数据做并发,缺少实战经验,对并发仅仅停留在了解,做不到精通,所以总是与大厂擦肩而过。我把私藏的这套并发体系的笔记和思维脑图分享出来,理论知识与项目实战的结合,我觉得只要你肯花时间用心学完这些,一定可以快速掌握并发编程。《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!战项目源码讲义》点击传送门即可获取!**

q16974058的博客 4332

C++实现生产者消费者

为应对系统的通信上消息收发的高耦合度,在接受和发送消息后设计一个缓存队列,并使用多线程生产者-消费者来进行收发解耦。避免通信上的拥堵情况。 利用C++内置函数实现生产者-消费者功能: private: std::deque<T> queue_; //缓存队列 size_t size_limit_; //缓存队列大小的限制 std::mutex lock_; //互斥锁 std::condition_variable empty_, full_; //并发条件变量类 s

YFaris的博客 3442

易灵思FPGA-软件Efinity和Modelsim联仿设置

文章目录前言一、modelsim破解过程二、使用步骤1.引入库2.读入数据总结欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智

qq_35221855的博客 5364

C++继承与多态 - 继承多态原理01

C++继承多态原理讲解

大秦坑王的专栏 2979

生产者消费者模式(c++实现)

c++实现生产者消费者模式

dsjfhdwasfhgakjs的博客 1714

uniapp(全端兼容) - 最新实现全局设置修改字体大小功能,统一修改全部页面所有文字的大小(标准/小/中/大字号切换,用户修改后整个项目立即生效)设置应用字体的大小(详细示例代码,一键复制开箱即用

uni-app,支付宝微信小程序,h5,手机端H5网页,移动端网站,安卓app,ios苹果app,nvue,全局设置字体大小,退出后还能记录字号大小,uniApp将全部页面的字体字号进行修改,uniapp设置改变全局字体大小功能,动态调整应用字体大小,详细教程,动态显示字体大小,可调整显示字体大小,如何解决不同端字体大小的问题,除了rem还有什么方法,设置全局字体大小,用户设置字号大小,应用字体大中小,实现用户全局设置应用字体大小,老年模式字体设置思路,h5端不行怎么办,移动端不生效,修改全局字号,一键改整

✅ 精选推荐文章 8885

C++实现生产者和消费者模型

C++实现生产者和消费者模型 C++实现生产者和消费者模型1、实现细节1、单生产者-单消费者模型参考 C++实现生产者和消费者模型 1、实现细节 具体的实现逻辑是构建一个queue来存储生产的数据,queue不满时可以生产,不空时可以消费。 对于这个队列,采用阻塞队列的实现思路。 先实现构造函数,初始化一个unique_lock供condition_variable使用。 如何在类里面使用unique_lock等需要初始化,并且初始化会加锁的对象。这要研究下。我的理解是构造列表初始化,然后函数体里unl

JMW1407的博客 1万+

Visual Studio调试技巧与实用方法总结(实战经验分享)

本文根据多年的项目实战经验,详细介绍一些Visual Studio常用的高效调试手段与技巧。

dvlinker的技术专栏 3万+

核磁共振常用的文件格式介绍:NIfTI volume 格式 (*.nii), GIFTI 格式 (*.gii), CIFTI 格式 (*.nii)

NIfTI volume 格式 (*.nii)GIFTI 格式 (*.gii)CIFTI 格式 (*.nii)Scene file文件 (*.scene)规格文件 (*.spec)解剖 (*.annot)一个场景文件包含一个或多个场景;每个场景实际上是保存时 wb_view 内部状态的快照。这包括有关加载哪些文件、如何显示、如何配置选项卡的信息(选择了哪些表面、在每个层中选择了哪些文件、打开了哪些层、哪些视图旋转、调色板设置、平铺选项卡等),以及在它们上面添加了哪些注释(文本、箭头、圆圈等)。

从事脑科学核磁共振方法学研究,在Nature communications等权威期刊发表研究论文,熟练掌握磁共振处理方法和统计学方法,欢迎大家和我交流。 3043

生产者消费者问题C++实现

生产者消费者问题C++实现 2020/10/11 11:23 问题 设计C/C++程序(可以嵌入汇编语言),以忙等待方式实现信号量及其P、V操作。利用你实现的信号量,实现生产者-消费者问题。给出实现方法、主要源代码和测试结果。 代码 # include<iostream> # include<thread> # include<vector> # include<mutex> # include<condition_variable> # inc

dalao_whs的博客 4156

【华为OD机试真题】390、AI面板识别 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS)

题目描述 >AI识别到面板上有N(1 ≤ N ≤ 100)个指示灯,灯大小一样,任意两个之间无重叠。   由于AI识别误差,每次别到的指示灯位置可能有差异,以4个坐标值描述AI识别的指示灯的大小和位置(左上角x1,y1,右下角x2,y2),   请输出先行后列排序的指示灯的编号,排序规则:   1、每次在尚未排序的灯中挑选最高的灯作为的基准灯   2、找出和基准灯属于同一行所有的灯进行排序。两个灯高低偏差不超过灯半径算同一行(即两个灯坐标的差 ≤ 灯高度的一半)

KJ.JK 1804

C++实现生产者消费者队列

C++实现生产者消费者队列分析程序队列的类生产者逻辑消费者逻辑主函数结果分析源码地址 分析 首先,我们的生产者与消费者队列需要满足同步与互斥关系,就需要一把互斥锁,以及生产者与消费者各自的条件变量。 其次,我们可以利用C++中STL里的queue队列来进行实现,但是我们需要对push,pop进行修改,因为STL库的函数不一定能满足互斥条件。也就是不一定安全。 最后,所有资源在程序结束后一定要记得释...

duchenlong的博客 3053

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

C++版本的生产者消费者模型

C++版生产者消费者模型 字节跳动三面提到的手写代码,当时没能写出来。这几天补了一下,在此记录一下。 生产者消费者模型本身主要是利用一个缓冲区来存储数据,从而减弱生产者和消费者之间的直接关系,提高多线程下程序效率。 代码 https://github.com/Huang-Jin/ProducerConsumerDemo 参考资料 https://blog.youkuaiyun.com/lvxin153537...

武陵人的博客 3082

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

《操作系统实验》C++实现生产者-消费者问题

生产者-消费者问题1 实验内容及要求2 实验环境3 实验设计3.1 问题描述3.2 基本思想3.2.1 生产者线程3.2.2 消费者线程3.2.3 同步的实现3.3 数据结构4 实验源码5 实验总结 1 实验内容及要求 1、模拟生产者—消费者问题; 2、程序要添加适当的注释,程序的书写要采用缩进格式; 3、程序要具在一定的健壮性,即当输入数据非法时,程序也能适当地做出反应; 4、程序要做到界面友好,在程序运行时用户可以根据相应的提示信息进行操作。 2 实验环境 windows 10,Visual Studi

weixin_44197749的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C++实现生产者消费者模型

生产者-消费者模型是一种用于解决多线程同步问题的经典设计模式,常见于缓冲区管理、任务调度等场景。该模型的核心是两个角色:生产者和消费者。通过共享缓冲区(通常是队列)进行协作。

科技之隅的博客 1352

【Linux | C++ 】生产者消费者模型(Linux系统下C++ 代码模拟实现)

生产者消费者模型是多线程编程中的一个经典案例,它涉及到两类线程:生产者和消费者。生产者线程不断地生成数据,并将数据放入一个缓冲区中,消费者线程则不断地从缓冲区中获取数据,并进行相应的处理。在这个过程中,为了保证数据的完整性和正确性,需要使用同步机制来协调两类线程之间的操作,以避免数据竞争和死锁等问题的发生。本文将介绍如何使用条件变量来实现生产者消费者模型,帮助读者更好地理解多线程编程中的同步机制和技术。

Yawesh的博客 3849

C++11实现生产者消费者模型

C++11实现生产者消费者模型 生产者消费者模型是什么 简单地举个例子,一个线程(或者进程)在往一个区域(可以使内存或其他地方)写数据,而同时有另外一个线程在取数据,这就存在了一个问题,存储的区域有限,数据存满了写数据的线程怎么办,还有数据空了,取数据的线程怎么处理,这时候就需要该模型来处理了。 原理 存储的数据的区域可以用一个队列来模拟,然后我们通过C++11提供的条件变量来通知写入线程在数据...

github_39553168的博客 3006

生产者消费者问题 C++实现

生产者消费者问题 C++实现 知识准备 thread 介绍 成员类 成员函数 sleep_for 介绍 mutex 介绍 成员函数 unique_lock 介绍 成员函数 codition_variable 介绍 成员函数 代码示例 生产者消费者问题 C++实现 知识准备 thread 介绍 定位于头文件的class thread 表示...

陈浩的博客 3万+

kafka C++ 生产者 消费者

使用的是rdkafka这个库,可以到网上下载. 下面是生产者和消费者C++编程客户端. #include #include #include #include #include #include #include #include #include "rdkafka.h" const int PRODUCER_INIT_FAILE

昨天的你 2万+
上一篇: 希尔排序
xdc_zy
博客等级 码龄9年 4粉丝 3原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值