Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 6863

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qthreadpool.cpp -->
  <title>Qt 4.8: QThreadPool Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtcore.html">QtCore</a></li>
<li>QThreadPool</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QThreadPool Class Reference</h1>
<!-- $$$QThreadPool-brief -->
<p>The QThreadPool class manages a collection of QThreads. <a href="#details">More...</a></p>
<!-- @@@QThreadPool -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QThreadPool&gt;</span></pre><p><b>Inherits: </b><a href="qobject.html">QObject</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#thread-safe">thread-safe</a>.</p>
<p>This class was introduced in Qt 4.4.</p>
<ul>
<li><a href="qthreadpool-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><a href="qthreadpool.html#activeThreadCount-prop">activeThreadCount</a></b> : const int</li>
<li class="fn"><b><a href="qthreadpool.html#expiryTimeout-prop">expiryTimeout</a></b> : int</li>
<li class="fn"><b><a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a></b> : int</li>
</ul>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#QThreadPool">QThreadPool</a></b> ( QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#dtor.QThreadPool">~QThreadPool</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#activeThreadCount-prop">activeThreadCount</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#expiryTimeout-prop">expiryTimeout</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#releaseThread">releaseThread</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#reserveThread">reserveThread</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#expiryTimeout-prop">setExpiryTimeout</a></b> ( int <i>expiryTimeout</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#maxThreadCount-prop">setMaxThreadCount</a></b> ( int <i>maxThreadCount</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#start">start</a></b> ( QRunnable * <i>runnable</i>, int <i>priority</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#tryStart">tryStart</a></b> ( QRunnable * <i>runnable</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#waitForDone">waitForDone</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#waitForDone-2">waitForDone</a></b> ( int <i>msecs</i> )</td></tr>
</table>
<ul>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QThreadPool * </td><td class="memItemRight bottomAlign"><b><a href="qthreadpool.html#globalInstance">globalInstance</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QThreadPool-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QThreadPool class manages a collection of QThreads.</p>
<p>QThreadPool manages and recyles individual <a href="qthread.html">QThread</a> objects to help reduce thread creation costs in programs that use threads. Each Qt application has one global QThreadPool object, which can be accessed by calling <a href="qthreadpool.html#globalInstance">globalInstance</a>().</p>
<p>To use one of the QThreadPool threads, subclass <a href="qrunnable.html">QRunnable</a> and implement the run() virtual function. Then create an object of that class and pass it to <a href="qthreadpool.html#start">QThreadPool::start</a>().</p>
<pre class="cpp"> <span class="keyword">class</span> HelloWorldTask : <span class="keyword">public</span> <span class="type"><a href="qrunnable.html">QRunnable</a></span>
 {
     <span class="type">void</span> run()
     {
         <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Hello world from thread&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qthread.html">QThread</a></span><span class="operator">::</span>currentThread();
     }
 }

 HelloWorldTask <span class="operator">*</span>hello <span class="operator">=</span> <span class="keyword">new</span> HelloWorldTask();
 <span class="comment">// QThreadPool takes ownership and deletes 'hello' automatically</span>
 <span class="type">QThreadPool</span><span class="operator">::</span><a href="qthreadpool.html#globalInstance">globalInstance</a>()<span class="operator">-</span><span class="operator">&gt;</span><a href="qthreadpool.html#start">start</a>(hello);</pre>
<p>QThreadPool deletes the <a href="qrunnable.html">QRunnable</a> automatically by default. Use <a href="qrunnable.html#setAutoDelete">QRunnable::setAutoDelete</a>() to change the auto-deletion flag.</p>
<p>QThreadPool supports executing the same <a href="qrunnable.html">QRunnable</a> more than once by calling tryStart(this) from within <a href="qrunnable.html#run">QRunnable::run</a>(). If autoDelete is enabled the <a href="qrunnable.html">QRunnable</a> will be deleted when the last thread exits the run function. Calling <a href="qthreadpool.html#start">start</a>() multiple times with the same <a href="qrunnable.html">QRunnable</a> when autoDelete is enabled creates a race condition and is not recommended.</p>
<p>Threads that are unused for a certain amount of time will expire. The default expiry timeout is 30000 milliseconds (30 seconds). This can be changed using <a href="qthreadpool.html#expiryTimeout-prop">setExpiryTimeout</a>(). Setting a negative expiry timeout disables the expiry mechanism.</p>
<p>Call <a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a>() to query the maximum number of threads to be used. If needed, you can change the limit with <a href="qthreadpool.html#maxThreadCount-prop">setMaxThreadCount</a>(). The default <a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a>() is <a href="qthread.html#idealThreadCount">QThread::idealThreadCount</a>(). The <a href="qthreadpool.html#activeThreadCount-prop">activeThreadCount</a>() function returns the number of threads currently doing work.</p>
<p>The <a href="qthreadpool.html#reserveThread">reserveThread</a>() function reserves a thread for external use. Use <a href="qthreadpool.html#releaseThread">releaseThread</a>() when your are done with the thread, so that it may be reused. Essentially, these functions temporarily increase or reduce the active thread count and are useful when implementing time-consuming operations that are not visible to the QThreadPool.</p>
<p>Note that QThreadPool is a low-level class for managing threads, see <a href="qtconcurrentrun.html#run">QtConcurrent::run</a>() or the other <a href="threads-qtconcurrent.html">Qt Concurrent</a> APIs for higher level alternatives.</p>
</div>
<p><b>See also </b><a href="qrunnable.html">QRunnable</a>.</p>
<!-- @@@QThreadPool -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$activeThreadCount-prop$$$activeThreadCount -->
<h3 class="fn"><a name="activeThreadCount-prop"></a><span class="name">activeThreadCount</span> : const <span class="type">int</span></h3>
<p>This property represents the number of active threads in the thread pool.</p>
<p><b>Note:</b> It is possible for this function to return a value that is greater than <a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a>(). See <a href="qthreadpool.html#reserveThread">reserveThread</a>() for more details.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>activeThreadCount</b></span> () const</td></tr>
</table>
<p><b>See also </b><a href="qthreadpool.html#reserveThread">reserveThread</a>() and <a href="qthreadpool.html#releaseThread">releaseThread</a>().</p>
<!-- @@@activeThreadCount -->
<!-- $$$expiryTimeout-prop$$$expiryTimeout$$$setExpiryTimeoutint -->
<h3 class="fn"><a name="expiryTimeout-prop"></a><span class="name">expiryTimeout</span> : <span class="type">int</span></h3>
<p>Threads that are unused for <i>expiryTimeout</i> milliseconds are considered to have expired and will exit. Such threads will be restarted as needed. The default <i>expiryTimeout</i> is 30000 milliseconds (30 seconds). If <i>expiryTimeout</i> is negative, newly created threads will not expire, e.g&#x2e;, they will not exit until the thread pool is destroyed.</p>
<p>Note that setting <i>expiryTimeout</i> has no effect on already running threads. Only newly created threads will use the new <i>expiryTimeout</i>. We recommend setting the <i>expiryTimeout</i> immediately after creating the thread pool, but before calling <a href="qthreadpool.html#start">start</a>().</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>expiryTimeout</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setExpiryTimeout</b></span> ( int <i>expiryTimeout</i> )</td></tr>
</table>
<!-- @@@expiryTimeout -->
<!-- $$$maxThreadCount-prop$$$maxThreadCount$$$setMaxThreadCountint -->
<h3 class="fn"><a name="maxThreadCount-prop"></a><span class="name">maxThreadCount</span> : <span class="type">int</span></h3>
<p>This property represents the maximum number of threads used by the thread pool.</p>
<p><b>Note:</b> The thread pool will always use at least 1 thread, even if <i>maxThreadCount</i> limit is zero or negative.</p>
<p>The default <i>maxThreadCount</i> is <a href="qthread.html#idealThreadCount">QThread::idealThreadCount</a>().</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>maxThreadCount</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setMaxThreadCount</b></span> ( int <i>maxThreadCount</i> )</td></tr>
</table>
<!-- @@@maxThreadCount -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QThreadPool[overload1]$$$QThreadPoolQObject* -->
<h3 class="fn"><a name="QThreadPool"></a>QThreadPool::<span class="name">QThreadPool</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs a thread pool with the given <i>parent</i>.</p>
<!-- @@@QThreadPool -->
<!-- $$$~QThreadPool[overload1]$$$~QThreadPool -->
<h3 class="fn"><a name="dtor.QThreadPool"></a>QThreadPool::<span class="name">~QThreadPool</span> ()</h3>
<p>Destroys the <a href="qthreadpool.html">QThreadPool</a>. This function will block until all runnables have been completed.</p>
<!-- @@@~QThreadPool -->
<!-- $$$globalInstance[overload1]$$$globalInstance -->
<h3 class="fn"><a name="globalInstance"></a><span class="type">QThreadPool</span> * QThreadPool::<span class="name">globalInstance</span> ()<tt> [static]</tt></h3>
<p>Returns the global <a href="qthreadpool.html">QThreadPool</a> instance.</p>
<!-- @@@globalInstance -->
<!-- $$$releaseThread[overload1]$$$releaseThread -->
<h3 class="fn"><a name="releaseThread"></a><span class="type">void</span> QThreadPool::<span class="name">releaseThread</span> ()</h3>
<p>Releases a thread previously reserved by a call to <a href="qthreadpool.html#reserveThread">reserveThread</a>().</p>
<p><b>Note:</b> Calling this function without previously reserving a thread temporarily increases <a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a>(). This is useful when a thread goes to sleep waiting for more work, allowing other threads to continue. Be sure to call <a href="qthreadpool.html#reserveThread">reserveThread</a>() when done waiting, so that the thread pool can correctly maintain the <a href="qthreadpool.html#activeThreadCount-prop">activeThreadCount</a>().</p>
<p><b>See also </b><a href="qthreadpool.html#reserveThread">reserveThread</a>().</p>
<!-- @@@releaseThread -->
<!-- $$$reserveThread[overload1]$$$reserveThread -->
<h3 class="fn"><a name="reserveThread"></a><span class="type">void</span> QThreadPool::<span class="name">reserveThread</span> ()</h3>
<p>Reserves one thread, disregarding <a href="qthreadpool.html#activeThreadCount-prop">activeThreadCount</a>() and <a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a>().</p>
<p>Once you are done with the thread, call <a href="qthreadpool.html#releaseThread">releaseThread</a>() to allow it to be reused.</p>
<p><b>Note:</b> This function will always increase the number of active threads. This means that by using this function, it is possible for <a href="qthreadpool.html#activeThreadCount-prop">activeThreadCount</a>() to return a value greater than <a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a>() .</p>
<p><b>See also </b><a href="qthreadpool.html#releaseThread">releaseThread</a>().</p>
<!-- @@@reserveThread -->
<!-- $$$start[overload1]$$$startQRunnable*int -->
<h3 class="fn"><a name="start"></a><span class="type">void</span> QThreadPool::<span class="name">start</span> ( <span class="type"><a href="qrunnable.html">QRunnable</a></span> * <i>runnable</i>, <span class="type">int</span> <i>priority</i> = 0 )</h3>
<p>Reserves a thread and uses it to run <i>runnable</i>, unless this thread will make the current thread count exceed <a href="qthreadpool.html#maxThreadCount-prop">maxThreadCount</a>(). In that case, <i>runnable</i> is added to a run queue instead. The <i>priority</i> argument can be used to control the run queue's order of execution.</p>
<p>Note that the thread pool takes ownership of the <i>runnable</i> if <a href="qrunnable.html#autoDelete">runnable-&gt;autoDelete()</a> returns true, and the <i>runnable</i> will be deleted automatically by the thread pool after the <a href="qrunnable.html#run">runnable-&gt;run()</a> returns. If <a href="qrunnable.html#autoDelete">runnable-&gt;autoDelete()</a> returns false, ownership of <i>runnable</i> remains with the caller. Note that changing the auto-deletion on <i>runnable</i> after calling this functions results in undefined behavior.</p>
<!-- @@@start -->
<!-- $$$tryStart[overload1]$$$tryStartQRunnable* -->
<h3 class="fn"><a name="tryStart"></a><span class="type">bool</span> QThreadPool::<span class="name">tryStart</span> ( <span class="type"><a href="qrunnable.html">QRunnable</a></span> * <i>runnable</i> )</h3>
<p>Attempts to reserve a thread to run <i>runnable</i>.</p>
<p>If no threads are available at the time of calling, then this function does nothing and returns false. Otherwise, <i>runnable</i> is run immediately using one available thread and this function returns true.</p>
<p>Note that the thread pool takes ownership of the <i>runnable</i> if <a href="qrunnable.html#autoDelete">runnable-&gt;autoDelete()</a> returns true, and the <i>runnable</i> will be deleted automatically by the thread pool after the <a href="qrunnable.html#run">runnable-&gt;run()</a> returns. If <a href="qrunnable.html#autoDelete">runnable-&gt;autoDelete()</a> returns false, ownership of <i>runnable</i> remains with the caller. Note that changing the auto-deletion on <i>runnable</i> after calling this function results in undefined behavior.</p>
<!-- @@@tryStart -->
<!-- $$$waitForDone[overload1]$$$waitForDone -->
<h3 class="fn"><a name="waitForDone"></a><span class="type">void</span> QThreadPool::<span class="name">waitForDone</span> ()</h3>
<p>Waits for each thread to exit and removes all threads from the thread pool.</p>
<!-- @@@waitForDone -->
<!-- $$$waitForDone$$$waitForDoneint -->
<h3 class="fn"><a name="waitForDone-2"></a><span class="type">bool</span> QThreadPool::<span class="name">waitForDone</span> ( <span class="type">int</span> <i>msecs</i> )</h3>
<p>This function overloads <a href="qthreadpool.html#waitForDone">waitForDone</a>().</p>
<p>Waits up to <i>msecs</i> milliseconds for all threads to exit and removes all threads from the thread pool. Returns true if all threads were removed; otherwise it returns false.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@waitForDone -->
</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Qt and respective logos are trademarks of The Qt Company Ltd 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>