升压:消防,忘记异步函数调用? [英] Boost: Fire and forget asynchronous function call?

查看:118
本文介绍了升压:消防,忘记异步函数调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调用的一杆的方式函数调用。什么是/ C ++为此在加速的最佳方式?

I would like invoke a function call in a one shot manner. What's the best way to do this in Boost / C++?

我想传递两个参数,不需要的结果。

I would like to pass it two parameters and do not need a result.

推荐答案

我没有使用过的boost ::线程一段时间,但我看到的的该类文档页:

I haven't used boost::thread in awhile but I see a quick example on the documentation page for the class:

void find_the_question(int the_answer);

boost::thread deep_thought_2(find_the_question,42);

我尽快它完成的功能相信,线程将退出。这可能不是你想要什么,一旦线程超出范围,它就会被破坏。如果这是行不通的,你可能需要创建一个长时间运行的线程池,然后通过你的仿函数作为的boost ::绑定组成。

I believe as soon as it finishes the function, the thread will exit. This may not be what you want in that once the thread goes out of scope, it will be destroyed. If that's not going to work, you probably need to create a long running thread pool and then pass your functors as boost::bind compositions.

这篇关于升压:消防,忘记异步函数调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆