Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > d4089b27bfd3289c6baf8b0975a53f9e > files > 652

poco-doc-1.3.6p1-1.fc13.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::ThreadPool</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.html" class="namespace">Poco</a></h1>
<h1 class="symbol">class ThreadPool</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Foundation<br />
<b>Package:</b> Threading<br />
<b>Header:</b> Poco/ThreadPool.h</p>
<h2>Description</h2>
<div class="description">
<p>A thread pool always keeps a number of threads running, ready to accept work. Creating and starting a threads can impose a significant runtime overhead to an application. A thread pool helps to improve the performance of an application by reducing the number of threads that have to be created (and destroyed again). Threads in a thread pool are re-used once they become available again. The thread pool always keeps a minimum number of threads running. If the demans for threads increases, additional threads are created. Once the demand for threads sinks again, no-longer used threads are stopped and removed from the pool. </p>
</div>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.ThreadPool.html#10915" title="Poco::ThreadPool::addCapacity()">addCapacity</a>, <a href="Poco.ThreadPool.html#10922" title="Poco::ThreadPool::allocated()">allocated</a>, <a href="Poco.ThreadPool.html#10923" title="Poco::ThreadPool::available()">available</a>, <a href="Poco.ThreadPool.html#10917" title="Poco::ThreadPool::capacity()">capacity</a>, <a href="Poco.ThreadPool.html#10938" title="Poco::ThreadPool::collect()">collect</a>, <a href="Poco.ThreadPool.html#10941" title="Poco::ThreadPool::createThread()">createThread</a>, <a href="Poco.ThreadPool.html#10939" title="Poco::ThreadPool::defaultPool()">defaultPool</a>, <a href="Poco.ThreadPool.html#10920" title="Poco::ThreadPool::getStackSize()">getStackSize</a>, <a href="Poco.ThreadPool.html#10940" title="Poco::ThreadPool::getThread()">getThread</a>, <a href="Poco.ThreadPool.html#10942" title="Poco::ThreadPool::housekeep()">housekeep</a>, <a href="Poco.ThreadPool.html#10937" title="Poco::ThreadPool::joinAll()">joinAll</a>, <a href="Poco.ThreadPool.html#10918" title="Poco::ThreadPool::setStackSize()">setStackSize</a>, <a href="Poco.ThreadPool.html#10924" title="Poco::ThreadPool::start()">start</a>, <a href="Poco.ThreadPool.html#10929" title="Poco::ThreadPool::startWithPriority()">startWithPriority</a>, <a href="Poco.ThreadPool.html#10936" title="Poco::ThreadPool::stopAll()">stopAll</a>, <a href="Poco.ThreadPool.html#10921" title="Poco::ThreadPool::used()">used</a></p>
<h2>Constructors</h2>
<h3><a name="10903">ThreadPool</a></h3>
<p class="decl"><a href="Poco.ThreadPool.html" title="class Poco::ThreadPool">ThreadPool</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;int minCapacity = 2,<br />&nbsp;&nbsp;&nbsp;&nbsp;int maxCapacity = 16,<br />&nbsp;&nbsp;&nbsp;&nbsp;int idleTime = 60,<br />&nbsp;&nbsp;&nbsp;&nbsp;int stackSize = 0<br />);</p>
<div class="description">
<p></p>
</div>
<h3><a name="10908">ThreadPool</a></h3>
<p class="decl"><a href="Poco.ThreadPool.html" title="class Poco::ThreadPool">ThreadPool</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; name,<br />&nbsp;&nbsp;&nbsp;&nbsp;int minCapacity = 2,<br />&nbsp;&nbsp;&nbsp;&nbsp;int maxCapacity = 16,<br />&nbsp;&nbsp;&nbsp;&nbsp;int idleTime = 60,<br />&nbsp;&nbsp;&nbsp;&nbsp;int stackSize = 0<br />);</p>
<div class="description">
<p>Creates a thread pool with minCapacity threads. If required, up to maxCapacity threads are created a <a href="Poco.NoThreadAvailableException.html" title="class Poco::NoThreadAvailableException">NoThreadAvailableException</a> exception is thrown. If a thread is running idle for more than idleTime seconds, and more than minCapacity threads are running, the thread is killed. Threads are created with given stack size. </p>
</div>
<h2>Destructor</h2>
<h3><a name="10914">~ThreadPool</a></h3>
<p class="decl">~<a href="Poco.ThreadPool.html" title="class Poco::ThreadPool">ThreadPool</a>();</p>
<div class="description">
<p>Currently running threads will remain active until they complete.  </p>
</div>
<h2>Member Functions</h2>
<h3><a name="10915">addCapacity</a></h3>
<p class="decl">void addCapacity(<br />&nbsp;&nbsp;&nbsp;&nbsp;int n<br />);</p>
<div class="description">
<p>Increases (or decreases, if n is negative) the maximum number of threads. </p>
</div>
<h3><a name="10922">allocated</a></h3>
<p class="decl">int allocated() const;</p>
<div class="description">
<p>Returns the number of currently allocated threads. </p>
</div>
<h3><a name="10923">available</a></h3>
<p class="decl">int available() const;</p>
<div class="description">
<p>Returns the number available threads. </p>
</div>
<h3><a name="10917">capacity</a></h3>
<p class="decl">int capacity() const;</p>
<div class="description">
<p>Returns the maximum capacity of threads. </p>
</div>
<h3><a name="10938">collect</a></h3>
<p class="decl">void collect();</p>
<div class="description">
<p>Stops and removes no longer used threads from the thread pool. Can be called at various times in an application's life time to help the thread pool manage its threads. Calling this method is optional, as the thread pool is also implicitly managed in calls to <a href="Poco.ThreadPool.html#10924" title="Poco::ThreadPool::start()">start</a>(), <a href="Poco.ThreadPool.html#10915" title="Poco::ThreadPool::addCapacity()">addCapacity</a>() and <a href="Poco.ThreadPool.html#10937" title="Poco::ThreadPool::joinAll()">joinAll</a>(). </p>
</div>
<h3><a name="10939">defaultPool</a> <img src="images/static.gif" alt="static" title="static" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">static <a href="Poco.ThreadPool.html" title="class Poco::ThreadPool">ThreadPool</a> &amp; defaultPool();</p>
<div class="description">
<p>Returns a reference to the default thread pool. </p>
</div>
<h3><a name="10920">getStackSize</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">int getStackSize() const;</p>
<div class="description">
<p>Returns the stack size used to create new threads. </p>
</div>
<h3><a name="10937">joinAll</a></h3>
<p class="decl">void joinAll();</p>
<div class="description">
<p>Waits for all threads to complete. </p>
</div>
<h3><a name="10918">setStackSize</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setStackSize(<br />&nbsp;&nbsp;&nbsp;&nbsp;int stackSize<br />);</p>
<div class="description">
<p>Sets the stack size for threads. New stack size applies only for newly created threads. </p>
</div>
<h3><a name="10924">start</a></h3>
<p class="decl">void start(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Runnable.html" title="class Poco::Runnable">Runnable</a> &amp; target<br />);</p>
<div class="description">
<p>Obtains a thread and starts the target. Throws a <a href="Poco.NoThreadAvailableException.html" title="class Poco::NoThreadAvailableException">NoThreadAvailableException</a> if no more threads are available. </p>
</div>
<h3><a name="10926">start</a></h3>
<p class="decl">void start(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Runnable.html" title="class Poco::Runnable">Runnable</a> &amp; target,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; name<br />);</p>
<div class="description">
<p>Obtains a thread and starts the target. Assigns the given name to the thread. Throws a <a href="Poco.NoThreadAvailableException.html" title="class Poco::NoThreadAvailableException">NoThreadAvailableException</a> if no more threads are available. </p>
</div>
<h3><a name="10929">startWithPriority</a></h3>
<p class="decl">void startWithPriority(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Thread.html#10815" title="enum  Poco::Thread::Priority">Thread::Priority</a> priority,<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Runnable.html" title="class Poco::Runnable">Runnable</a> &amp; target<br />);</p>
<div class="description">
<p>Obtains a thread, adjusts the thread's priority, and starts the target. Throws a <a href="Poco.NoThreadAvailableException.html" title="class Poco::NoThreadAvailableException">NoThreadAvailableException</a> if no more threads are available. </p>
</div>
<h3><a name="10932">startWithPriority</a></h3>
<p class="decl">void startWithPriority(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Thread.html#10815" title="enum  Poco::Thread::Priority">Thread::Priority</a> priority,<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Runnable.html" title="class Poco::Runnable">Runnable</a> &amp; target,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; name<br />);</p>
<div class="description">
<p>Obtains a thread, adjusts the thread's priority, and starts the target. Assigns the given name to the thread. Throws a <a href="Poco.NoThreadAvailableException.html" title="class Poco::NoThreadAvailableException">NoThreadAvailableException</a> if no more threads are available. </p>
</div>
<h3><a name="10936">stopAll</a></h3>
<p class="decl">void stopAll();</p>
<div class="description">
<p>Stops all running threads. Will also delete all thread objects. If used, this method should be the last action before the thread pool is deleted. </p>
</div>
<h3><a name="10921">used</a></h3>
<p class="decl">int used() const;</p>
<div class="description">
<p>Returns the number of currently used threads. </p>
</div>
<h3><a name="10941">createThread</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">PooledThread * createThread();</p>
<div class="description">
<p></p>
</div>
<h3><a name="10940">getThread</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">PooledThread * getThread();</p>
<div class="description">
<p></p>
</div>
<h3><a name="10942">housekeep</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void housekeep();</p>
<div class="description">
<p></p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright &copy; 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>

</div>
</body>
</html>