<legend id='DBEhk'><style id='DBEhk'><dir id='DBEhk'><q id='DBEhk'></q></dir></style></legend>
  • <i id='DBEhk'><tr id='DBEhk'><dt id='DBEhk'><q id='DBEhk'><span id='DBEhk'><b id='DBEhk'><form id='DBEhk'><ins id='DBEhk'></ins><ul id='DBEhk'></ul><sub id='DBEhk'></sub></form><legend id='DBEhk'></legend><bdo id='DBEhk'><pre id='DBEhk'><center id='DBEhk'></center></pre></bdo></b><th id='DBEhk'></th></span></q></dt></tr></i><div id='DBEhk'><tfoot id='DBEhk'></tfoot><dl id='DBEhk'><fieldset id='DBEhk'></fieldset></dl></div>

    <small id='DBEhk'></small><noframes id='DBEhk'>

  • <tfoot id='DBEhk'></tfoot>

      • <bdo id='DBEhk'></bdo><ul id='DBEhk'></ul>

        如何将参数传递给 boost::thread?

        How to pass an argument to boost::thread?(如何将参数传递给 boost::thread?)
      1. <tfoot id='ktxGz'></tfoot>

        1. <legend id='ktxGz'><style id='ktxGz'><dir id='ktxGz'><q id='ktxGz'></q></dir></style></legend>
            <tbody id='ktxGz'></tbody>
            <bdo id='ktxGz'></bdo><ul id='ktxGz'></ul>
              • <i id='ktxGz'><tr id='ktxGz'><dt id='ktxGz'><q id='ktxGz'><span id='ktxGz'><b id='ktxGz'><form id='ktxGz'><ins id='ktxGz'></ins><ul id='ktxGz'></ul><sub id='ktxGz'></sub></form><legend id='ktxGz'></legend><bdo id='ktxGz'><pre id='ktxGz'><center id='ktxGz'></center></pre></bdo></b><th id='ktxGz'></th></span></q></dt></tr></i><div id='ktxGz'><tfoot id='ktxGz'></tfoot><dl id='ktxGz'><fieldset id='ktxGz'></fieldset></dl></div>

                  <small id='ktxGz'></small><noframes id='ktxGz'>

                  本文介绍了如何将参数传递给 boost::thread?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  thread_ = boost::thread( boost::function< void (void)>( boost::bind( &clientTCP::run , this ) ) );  
                  

                  run 是否可能有这样的参数:

                  is it possible that run has an argument like this :

                  void clientTCP::run(boost:function<void(std::string)> func);
                  

                  如果是,我的 boost::thread 调用应该如何编写

                  and if yes how my boost::thread call should be written

                  谢谢.

                  推荐答案

                  下面的代码boost::bind( &clientTCP::run , this ) 定义了一个函数回调.它在当前实例(this)上调用函数run.使用 boost::bind,您可以执行以下操作:

                  The following code boost::bind( &clientTCP::run , this ) defines a function callback. It calls the function run on the current instance (this). With boost::bind you can do the following:

                  // Pass pMyParameter through to the run() function
                  boost::bind(&clientTCP::run, this, pMyParameter)
                  

                  请参阅此处的文档和示例:
                  http://www.boost.org/doc/libs/1_46_1/doc/html/thread/thread_management.html

                  See the documentation and example here:
                  http://www.boost.org/doc/libs/1_46_1/doc/html/thread/thread_management.html

                  如果你想构造一个实例带有函数的 boost::thread 或需要的可调用对象要提供的参数,这可以是通过传递额外的参数来完成到 boost::thread 构造函数:

                  If you wish to construct an instance of boost::thread with a function or callable object that requires arguments to be supplied, this can be done by passing additional arguments to the boost::thread constructor:

                  void find_the_question(int the_answer);
                  
                  boost::thread deep_thought_2(find_the_question,42);
                  

                  希望有所帮助.

                  这篇关于如何将参数传递给 boost::thread?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to limit the number of running instances in C++(C++中如何限制运行实例的数量)
                  Using boost::asio::async_read with stdin?(将 boost::asio::async_read 与 stdin 一起使用?)
                  How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?(如何找出特定 Boost 库需要哪些依赖项(即其他 Boost 库)?)
                  What#39;s the purpose of a leading quot;::quot; in a C++ method call(引导“::的目的是什么?在 C++ 方法调用中)
                  Boost Spirit x3: parse into structs(Boost Spirit x3:解析为结构体)
                  How boost auto-linking makes choice?(boost自动链接如何做出选择?)
                  • <bdo id='PTp5F'></bdo><ul id='PTp5F'></ul>

                    <legend id='PTp5F'><style id='PTp5F'><dir id='PTp5F'><q id='PTp5F'></q></dir></style></legend>
                    1. <tfoot id='PTp5F'></tfoot>

                        • <i id='PTp5F'><tr id='PTp5F'><dt id='PTp5F'><q id='PTp5F'><span id='PTp5F'><b id='PTp5F'><form id='PTp5F'><ins id='PTp5F'></ins><ul id='PTp5F'></ul><sub id='PTp5F'></sub></form><legend id='PTp5F'></legend><bdo id='PTp5F'><pre id='PTp5F'><center id='PTp5F'></center></pre></bdo></b><th id='PTp5F'></th></span></q></dt></tr></i><div id='PTp5F'><tfoot id='PTp5F'></tfoot><dl id='PTp5F'><fieldset id='PTp5F'></fieldset></dl></div>

                            <small id='PTp5F'></small><noframes id='PTp5F'>

                              <tbody id='PTp5F'></tbody>