<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # QThreadPool Class Reference ## [[QtCore](index.htm) module] 該QThreadPool類管理QThreads的集合。[More...](#details) 繼承[QObject](qobject.html)。 ### Methods * `__init__ (self, QObject?parent?=?None)` * `int activeThreadCount (self)` * `int expiryTimeout (self)` * `int maxThreadCount (self)` * `releaseThread (self)` * `reserveThread (self)` * `setExpiryTimeout (self, int?expiryTimeout)` * `setMaxThreadCount (self, int?maxThreadCount)` * `start (self, QRunnable?runnable, int?priority?=?0)` * `bool tryStart (self, QRunnable?runnable)` * `waitForDone (self)` * `bool waitForDone (self, int?msecs)` ### Static Methods * `QThreadPool globalInstance ()` * * * ## Detailed Description 該QThreadPool類管理QThreads的集合。 QThreadPool管理及recyles個人[QThread](qthread.html)對象以幫助減少在使用線程的程序線程的創建成本。每個Qt的應用程序有一個全局QThreadPool對象,它可以通過調用訪問[globalInstance](qthreadpool.html#globalInstance)( ) 。 要使用一個QThreadPool線程,子類[QRunnable](qrunnable.html)并實現run ( )虛函數。然后創建類的一個對象,并把它傳遞給[QThreadPool.start](qthreadpool.html#start)( ) 。 ``` class HelloWorldTask : public [QRunnable](qrunnable.html) { void run() { qDebug() << "Hello world from thread" << [QThread](qthread.html).currentThread(); } } HelloWorldTask *hello = new HelloWorldTask(); // QThreadPool takes ownership and deletes 'hello' automatically QThreadPool.globalInstance()->start(hello); ``` QThreadPool刪除[QRunnable](qrunnable.html)自動默認。使用[QRunnable.setAutoDelete](qrunnable.html#setAutoDelete)()來更改自動刪除標志。 QThreadPool支持執行相同[QRunnable](qrunnable.html)不止一次被從內部調用tryStart (本)[QRunnable.run](qrunnable.html#run)( ) 。如果autoDelete啟用[QRunnable](qrunnable.html)當最后一個線程退出運行功能將被刪除。調用[start](qthreadpool.html#start)()多次使用相同的[QRunnable](qrunnable.html)當autoDelete啟用創造競爭條件,因此不推薦。 線程是未使用一定量的時間會過期。默認的到期超時為30000毫秒( 30秒) 。這可以使用被改變[setExpiryTimeout](qthreadpool.html#expiryTimeout-prop)( ) 。設置一個負的到期超時禁用屆滿機制。 Call [maxThreadCount](qthreadpool.html#maxThreadCount-prop)( )來查詢所使用的最大線程數。如果需要,你可以更改該限制[setMaxThreadCount](qthreadpool.html#maxThreadCount-prop)( ) 。默認[maxThreadCount](qthreadpool.html#maxThreadCount-prop)()是[QThread.idealThreadCount](qthread.html#idealThreadCount)( ) 。該[activeThreadCount](qthreadpool.html#activeThreadCount-prop)( )函數返回目前正在做的工作線程數。 該[reserveThread](qthreadpool.html#reserveThread)( )函數保留一個線程外用。使用[releaseThread](qthreadpool.html#releaseThread)()時,你正在與線程完成的,以便它可以被重新使用。從本質上講,這些功能暫時增加或減少活動線程數和執行耗時的操作是不可見的QThreadPool時是有用的。 注意, QThreadPool是用于管理線程一個低級別的類,見[QtConcurrent.run](index.htm#run)()或其他[Qt Concurrent](index.htm)API進行更高層次的替代品。 * * * ## Method Documentation ``` QThreadPool.__init__ (self, QObject?parent?=?None) ``` 該_parent_的說法,如果不是沒有,原因_self_通過Qt的,而不是PyQt的擁有。 構造一個線程池與給定_parent_。 ``` int QThreadPool.activeThreadCount (self) ``` ``` int QThreadPool.expiryTimeout (self) ``` ``` QThreadPool QThreadPool.globalInstance () ``` [](qthreadpool.html) [返回全局](qthreadpool.html)[QThreadPool](qthreadpool.html)實例。 ``` int QThreadPool.maxThreadCount (self) ``` ``` QThreadPool.releaseThread (self) ``` 發布一個線程以前通過調用保留[reserveThread](qthreadpool.html#reserveThread)( ) 。 **Note:**調用此函數之前沒有預留一個線程暫時增加[maxThreadCount](qthreadpool.html#maxThreadCount-prop)( ) 。當一個線程進入睡眠狀態,等待更多的工作,讓其他線程繼續,這是很有用的。一定要調用[reserveThread](qthreadpool.html#reserveThread)( )進行等待,從而使線程池可以維持正確的時[activeThreadCount](qthreadpool.html#activeThreadCount-prop)( ) 。 **See also** [reserveThread](qthreadpool.html#reserveThread)( ) 。 ``` QThreadPool.reserveThread (self) ``` 準備一個線程,無視[activeThreadCount](qthreadpool.html#activeThreadCount-prop)()和[maxThreadCount](qthreadpool.html#maxThreadCount-prop)( ) 。 一旦你與線程,調用來完成[releaseThread](qthreadpool.html#releaseThread)()以允許它被重復使用。 **Note:**此功能將隨時增加活動線程的數量。這意味著,通過使用此功能,可以為[activeThreadCount](qthreadpool.html#activeThreadCount-prop)( )返回的值大于[maxThreadCount](qthreadpool.html#maxThreadCount-prop)( ) 。 **See also** [releaseThread](qthreadpool.html#releaseThread)( ) 。 ``` QThreadPool.setExpiryTimeout (self, int?expiryTimeout) ``` ``` QThreadPool.setMaxThreadCount (self, int?maxThreadCount) ``` ``` QThreadPool.start (self, QRunnable?runnable, int?priority?=?0) ``` 保留一個線程,并使用它來運行_runnable_,除非這個線程將會使當前線程數超過[maxThreadCount](qthreadpool.html#maxThreadCount-prop)( ) 。在這種情況下,_runnable_被添加到一個運行隊列來代替。該_priority_參數可以用來控制執行的運行隊列的順序。 需要注意的是線程池需要的所有權_runnable_如果[runnable-&gt;autoDelete()](qrunnable.html#autoDelete)返回True ,而_runnable_會后,由線程池自動刪除[runnable-&gt;run()](qrunnable.html#run)回報。如果[runnable-&gt;autoDelete()](qrunnable.html#autoDelete)返回False,所有權_runnable_保持與來電者。注意,改變在自動刪除_runnable_調用此函數后,會導致不確定的行為。 ``` bool QThreadPool.tryStart (self, QRunnable?runnable) ``` 嘗試保留一個線程來運行_runnable_。 如果沒有可用的線程在調用的時候,那么這個函數不執行任何操作并返回False 。否則,_runnable_立即運行使用一個可用的線程,這個函數返回True。 需要注意的是線程池需要的所有權_runnable_如果[runnable-&gt;autoDelete()](qrunnable.html#autoDelete)返回True ,而_runnable_會后,由線程池自動刪除[runnable-&gt;run()](qrunnable.html#run)回報。如果[runnable-&gt;autoDelete()](qrunnable.html#autoDelete)返回False,所有權_runnable_保持與來電者。注意,改變在自動刪除_runnable_調用此函數后會導致不確定的行為。 ``` QThreadPool.waitForDone (self) ``` 等待每一個線程退出并刪除所有線程的線程池。 ``` bool QThreadPool.waitForDone (self, int?msecs) ``` 這個函數的重載[waitForDone](qthreadpool.html#waitForDone)( ) 。 最多等待_msecs_毫秒所有線程退出并刪除所有線程的線程池。返回True如果被拆除的所有線程,否則返回False 。 此功能被引入Qt的4.8 。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看