<legend id='E4agP'><style id='E4agP'><dir id='E4agP'><q id='E4agP'></q></dir></style></legend>

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

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

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

        如何可靠地判断 boost 线程是否已退出其 run 方法?

        How can I tell reliably if a boost thread has exited its run method?(如何可靠地判断 boost 线程是否已退出其 run 方法?)

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

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

              <tbody id='RQGiQ'></tbody>

            1. <legend id='RQGiQ'><style id='RQGiQ'><dir id='RQGiQ'><q id='RQGiQ'></q></dir></style></legend>
                <bdo id='RQGiQ'></bdo><ul id='RQGiQ'></ul>

                  本文介绍了如何可靠地判断 boost 线程是否已退出其 run 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我认为 joinable 会表明这一点,但是,情况似乎并非如此.

                  I assumed joinable would indicate this, however, it does not seem to be the case.

                  在一个工人类中,我试图表明它仍在通过谓词处理:

                  In a worker class, I was trying to indicate that it was still processing through a predicate:

                  bool isRunning(){return thread_->joinable();}
                  

                  一个已经退出的线程不是不能加入吗?我错过了什么...... boost thread::joinable 是什么意思?

                  Wouldn't a thread that has exited not be joinable? What am I missing... what is the meaning of boost thread::joinable?

                  推荐答案

                  由于您可以在线程终止后加入,所以 joinable() 仍然会返回 true,直到您调用 join() 或 detach().如果您想知道某个线程是否仍在运行,您应该能够调用 timed_join,等待时间为 0.请注意,这可能会导致竞争条件,因为线程可能会在调用后立即终止.

                  Since you can join a thread even after it has terminated, joinable() will still return true until you call join() or detach(). If you want to know if a thread is still running, you should be able to call timed_join with a wait time of 0. Note that this can result in a race condition since the thread may terminate right after the call.

                  这篇关于如何可靠地判断 boost 线程是否已退出其 run 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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自动链接如何做出选择?)

                    <tbody id='54tT9'></tbody>

                    <bdo id='54tT9'></bdo><ul id='54tT9'></ul>

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

                        <small id='54tT9'></small><noframes id='54tT9'>

                          <legend id='54tT9'><style id='54tT9'><dir id='54tT9'><q id='54tT9'></q></dir></style></legend>