久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

    1. <i id='YyVkz'><tr id='YyVkz'><dt id='YyVkz'><q id='YyVkz'><span id='YyVkz'><b id='YyVkz'><form id='YyVkz'><ins id='YyVkz'></ins><ul id='YyVkz'></ul><sub id='YyVkz'></sub></form><legend id='YyVkz'></legend><bdo id='YyVkz'><pre id='YyVkz'><center id='YyVkz'></center></pre></bdo></b><th id='YyVkz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='YyVkz'><tfoot id='YyVkz'></tfoot><dl id='YyVkz'><fieldset id='YyVkz'></fieldset></dl></div>
        <bdo id='YyVkz'></bdo><ul id='YyVkz'></ul>

      <tfoot id='YyVkz'></tfoot>

      如何保證快速關閉我的 win32 應用程序?

      How do I guarantee fast shutdown of my win32 app?(如何保證快速關閉我的 win32 應用程序?)
    2. <i id='KghyC'><tr id='KghyC'><dt id='KghyC'><q id='KghyC'><span id='KghyC'><b id='KghyC'><form id='KghyC'><ins id='KghyC'></ins><ul id='KghyC'></ul><sub id='KghyC'></sub></form><legend id='KghyC'></legend><bdo id='KghyC'><pre id='KghyC'><center id='KghyC'></center></pre></bdo></b><th id='KghyC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KghyC'><tfoot id='KghyC'></tfoot><dl id='KghyC'><fieldset id='KghyC'></fieldset></dl></div>

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

      • <legend id='KghyC'><style id='KghyC'><dir id='KghyC'><q id='KghyC'></q></dir></style></legend>

            <bdo id='KghyC'></bdo><ul id='KghyC'></ul>
              <tbody id='KghyC'></tbody>

              <tfoot id='KghyC'></tfoot>

                本文介紹了如何保證快速關閉我的 win32 應用程序?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個 C++ Win32 應用程序,它有許多線程,當用戶想要關閉應用程序時,這些線程可能忙于執行 IO(HTTP 調用等).目前,我玩得很好,在從 main 返回之前等待所有線程結束.有時,這需要比我想要的更長的時間,實際上,讓用戶在我可以退出時等待似乎毫無意義.但是,如果我繼續從 main 返回,我很可能會崩潰,因為析構函數開始被調用,而仍然有線程在使用對象.

                I've got a C++ Win32 application that has a number of threads that might be busy doing IO (HTTP calls, etc) when the user wants to shutdown the application. Currently, I play nicely and wait for all the threads to end before returning from main. Sometimes, this takes longer than I would like and indeed, it seems kind of pointless to make the user wait when I could just exit. However, if I just go ahead and return from main, I'm likely to get crashes as destructors start getting called while there are still threads using the objects.

                因此,認識到在理想的、柏拉圖式的美德世界中,最好的做法是等待所有線程退出然后干凈利落地關閉,那么現實世界的下一個最佳解決方案是什么?簡單地使線程退出更快可能不是一種選擇.目標是盡快終止進程,例如,可以在其上安裝新版本.我正在做的唯一磁盤 IO 是在事務數據庫中,所以我不太擔心拔掉它的插頭.

                So, recognizing that in an ideal, platonic world of virtue, the best thing to do would be to wait for all the threads to exit and then shutdown cleanly, what is the next best real world solution? Simply making the threads exit faster may not be an option. The goal is to get the process dead as quickly as possible so that, for example, a new version can be installed over it. The only disk IO I'm doing is in a transactional db, so I'm not terribly concerned about pulling the plug on that.

                推薦答案

                使用重疊 IO,這樣您就可以始終控制處理 I/O 的線程,并且可以隨時停止它們;您可以讓它們等待 IOCP 并可以向其發布應用程序級別的關閉代碼,或者您可以等待 OVERLAPPED 結構中的事件并等待您的所有線程請立即關閉"事件.

                Use overlapped IO so that you're always in control of the threads that are dealing with your I/O and can always stop them at any point; you either have them waiting on an IOCP and can post an application level shutdown code to it, OR you can wait on the event in your OVERLAPPED structure AND wait on your 'all threads please shutdown now' event as well.

                總而言之,避免阻塞無法取消的呼叫.

                In summary, avoid blocking calls that you can't cancel.

                如果你不能,并且你在執行 IO 的阻塞套接字調用中被卡住,那么你總是可以從已經決定是時候關閉的線程關閉套接字并讓執行 IO 的線程總是檢查重試之前的立即關閉"事件...

                If you can't and you're stuck in a blocking socket call doing IO then you could always just close the socket from the thread that has decided that it's time to shut down and have the thread that's doing IO always check the 'shutdown now' event before retrying...

                這篇關于如何保證快速關閉我的 win32 應用程序?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                In what ways do C++ exceptions slow down code when there are no exceptions thown?(當沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                When and how should I use exception handling?(我應該何時以及如何使用異常處理?)
                Scope of exception object in C++(C++中異常對象的范圍)
                Catching exceptions from a constructor#39;s initializer list(從構造函數的初始化列表中捕獲異常)
                Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)
                  <tbody id='Oaasf'></tbody>
                    <bdo id='Oaasf'></bdo><ul id='Oaasf'></ul>

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

                      <tfoot id='Oaasf'></tfoot>

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

                          主站蜘蛛池模板: 九九亚洲 | 国产精品一区在线 | 中文字幕成人av | av在线一区二区 | 亚洲美女在线一区 | 欧美激情精品久久久久久免费 | 国产高清精品在线 | 九九九久久国产免费 | 四虎影视在线 | 精品国产第一区二区三区 | 毛片1| 免费高潮视频95在线观看网站 | 午夜精品视频在线观看 | 国产激情一区二区三区 | 一区二区三区欧美在线观看 | 超黄视频网站 | 91精品国产综合久久久久久丝袜 | 一区二区视频 | 亚洲一区二区久久 | 欧美激情网站 | 国产99热在线 | 久久国产精品一区二区三区 | 国产成人一区二区三区久久久 | 中文字幕免费 | 97色在线视频 | 国产在线视频一区二区 | 成人激情免费视频 | 久久久久久久久99 | 日韩欧美国产精品一区二区三区 | 亚洲成人网在线观看 | 久久九精品 | 亚洲精品自在在线观看 | 成人久久久 | 久久久久一区 | 美女露尿口视频 | 日本黄色一级片视频 | 亚洲狠狠 | 欧美一级视频 | 久久免费视频在线 | 国产欧美日韩一区二区三区在线 | 亚洲精品片 |