首页 文章

如何使用boost :: asio :: io_service在C 11线程之间调度作业

提问于
浏览
0

我需要在多核架构上执行大量相对较短的任务 . 为此我想使用固定大小的线程池和 Actuator 的一些可靠的实现 .

我在这篇文章中读到了关于boost :: asio和io_service的内容How to create a thread pool using boost in C++?但是这使用了boost线程,而在很多地方我的代码使用c 11 thread_local修饰符作为局部变量(出于性能原因),因此我想我被迫使用c 11个主题 .

boost线程实现是否与c 11 thread_local变量兼容?

使用带有c 11线程的io_service :: run方法是否安全,而不是使用boost :: thread?

1 回答

  • 3

    使用带有c 11线程的io_service :: run方法,而不是使用boost :: thread是否安全?

    是的,我使用 std::threadboost::asio ,它工作正常 . 我也使用 std::bind 而不是 boost::bind . 你可以找一个例子here

    boost线程实现是否与c 11 thread_local变量兼容?

    我不知道这一点,但如果你使用 std::thread 应该是无关紧要的

相关问题