java 绑定线程_将函数参数绑定到线程

我尝试使用boost调用带参数的函数,但它不起作用 . 代码是这样的

void Simulate::cr_number_threaded(lint nodes) {

for(lint i = 0; i < trials_per_thread; i++) {

// code

}

}

void Simulate::run_cr_number() {

vec_cr_number.clear();

boost::thread t[threads];

for(int i = 0; i < n_s.size(); i++) {

// n_s[i] is the current number of nodes

for(int t_idx = 0; t_idx < threads; t_idx++)

t[t_idx] = boost::thread(cr_number_threaded, n_s[i]);

// etc...

}

}

我得到的错误如下:

Simulate.cpp:在成员函数'void Simulate :: run_cr_number()'中:Simulate.cpp:27:错误:没有用于调用'boost :: thread :: thread(,long int&)'的匹配函数

更新:我遵循了建议 . 使用我得到的第一个解决方案

Simulate.cpp:在成员函数'void Simulate :: run_cr_number()'中:Simulate.cpp:28:错误:没有用于调用'bind(,long int&)'的匹配函数../../boost_1_44_0/boost/ bind / bind.hpp:1472:注意:候选者是:boost :: _ bi :: bind_t :: type> boost :: bind(F,A1)[with F = void(Simulate :: *)(lint),A1 = long int] ../../boost_1_44_0/boost/bind/bind.hpp:1728:注意:boost :: _ bi :: bind_t :: type,boost :: _ mfi :: dm,typename boost :: _ bi :: list_av_1 :: type> boost :: bind(MT :: *,A1)[A1 = long int,M = void()(lint),T = Simulate]

使用第二个,我得到了这个

Simulate.cpp:在成员函数'void Simulate :: run_cr_number()'中:Simulate.cpp:28:错误:没有匹配函数来调用'boost :: thread :: swap(boost :: _ bi :: bind_t,boost :: _ bi :: list2,boost :: _ bi :: value >>)'../../boost_1_44_0/boost/thread/detail/thread.hpp:310:注意:候选人是:void boost :: thread ::掉期(升压::线程和)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值