TBB之task

这部分介绍Intel TBB task schedulertask scheduler是一个loop模板的引擎,在实际应用中,你应该使用loop模板而不是task scheduler,因为模板隐藏了调度器的复杂度。然而,如果你有一个算法不能映射到高阶模板中的一个,请使用task scheduler

#include "tbb/tbb.h"
#include <cstdio>
using namespace tbb;
class say_hello
{
const char * id;
public:
    say_hello(const char * s) : id(s) { }

    void operator( ) () const{
        printf("hello from task %s\n",id);
    }
};

int main( )
{
task_group tg;
tg.run(say_hello("1")); // spawn 1st task and return
tg.run(say_hello("2")); // spawn 2nd task and return
tg.wait( ); // wait for tasks to complete
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值