linux c++中的boost::XXX和线程处理

Qt QThread

https://blog.csdn.net/u013488085/article/details/51333756

http://blog.sina.com.cn/s/blog_a6fb6cc90102vs8z.html

 

 boost::shared_ptr

https://www.cnblogs.com/helloamigo/p/3575098.html

 

boost::function的用法

https://blog.csdn.net/zgaoq/article/details/74332084

https://blog.csdn.net/zgaoq/article/details/74354928

 

Linux信号量 sem_t简介

https://blog.csdn.net/evsqiezi/article/details/8061176

 

linux线程互斥量pthread_mutex_t使用简介

https://blog.csdn.net/guotianqing/article/details/80559865

 

 Linux poll 机制:

理论:https://blog.csdn.net/zhuxiaoping54532/article/details/51701549

https://blog.csdn.net/lizuobin2/article/details/52703976

实例:https://blog.csdn.net/moxiaoxuan123/article/details/61622531

 

主要代码

引用和定义

qt开发环境.pro文件:

LIBS += -L/usr/local/lib -lboost_system -lboost_thread -lboost_filesystem

头文件:

// 必须:
#include <boost/thread.hpp>

//可选

#include <QObject>
#include <QThread>
#include <semaphore.h>
#include <boost/function.hpp>

变量:

    boost::thread *hThread;
    bool continueThread;

使用

调用

int main(int argc, char *argv[])

{

...

startThread();

...

}

开始


void  startThread():
{
    continueThread = true;
    hThread = new boost::thread(boost::bind(&process, this));
}

处理

void process()

{
    ...
    while (true) {
       ...
    }
}

结束

void  stop()
{
    continueThread = false;

    if (hThread)
    {
        hThread->join();
        delete hThread;
        hThread = 0;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值