Tars框架下的线程池TC_ThreadPool负责处理lambda式任务
发布时间
阅读量:
阅读量
在多线程程序的开发过程中,线程池几乎成为不可或缺的组成部分。
本文将对Tars框架中的线程池TC_ThreadPool进行实际操作,本实例中使用一个lambda函数作为线程执行的具体任务,相关代码如下:
#pragma once
#include "../../tars/util/include/util/tc_thread_pool.h"
#include <iostream>
#include <set>
using namespace std;
using namespace tars;
namespace lesliefishtest
{
class TestThreadPool
{
public:
static void testRunLambdaTask()
{
TC_ThreadPool tpool;
// 4个线程
tpool.init(4);
// 启动线程池,tpool.start();
tpool.start();
全部评论 (0)
还没有任何评论哟~
