workspace
workspace copied to clipboard
关于submitForReturn函数是否能执行带参数的函数的问题

是不带参数的,你可以用std::bind或者lambda捕获局部变量来传入参数。


#include <hipe/hipe.h>
double func(double x) {
hipe::util::print("hello world");
return x;
}
int main() {
hipe::SteadyThreadPond poo(10);
auto tmp = poo.submitForReturn(std::bind(func, 2.5));
poo.waitForTasks();
hipe::util::print(tmp.get());
}
没问题呀
jack@LAPTOP-9HN8DLAB:~/code/Hipe/interfaces$ g++ tmp.cc -I ../include -lpthread && ./a.out
hello world
2.5