You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

185 lines
12 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>tbb::task_scheduler_init Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li id="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
<li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
</ul></div>
<div class="nav">
<a class="el" href="a00428.html">tbb</a>::<a class="el" href="a00355.html">task_scheduler_init</a></div>
<h1>tbb::task_scheduler_init Class Reference<br>
<small>
[<a class="el" href="a00446.html">Task Scheduling</a>]</small>
</h1><!-- doxytag: class="tbb::task_scheduler_init" -->Class delimiting the scope of task scheduler activity.
<a href="#_details">More...</a>
<p>
<code>#include &lt;task_scheduler_init.h&gt;</code>
<p>
<a href="a00145.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void __TBB_EXPORTED_METHOD&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00355.html#d476053cc712e572554823492a5229ce">initialize</a> (int number_of_threads=<a class="el" href="a00355.html#8f5988e2b0fbb2d533fcbb7f2583743f">automatic</a>)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Ensure that scheduler exists for this thread. <a href="#d476053cc712e572554823492a5229ce"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void __TBB_EXPORTED_METHOD&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00355.html#d5ed214a8bb53b0466ed91ff4734b9a3">initialize</a> (int number_of_threads, stack_size_type thread_stack_size)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The overloaded method with stack size parameter. <a href="#d5ed214a8bb53b0466ed91ff4734b9a3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="f73257e04cb7fb9bd5be2b635d9016f1"></a><!-- doxytag: member="tbb::task_scheduler_init::terminate" ref="f73257e04cb7fb9bd5be2b635d9016f1" args="()" -->
void __TBB_EXPORTED_METHOD&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00355.html#f73257e04cb7fb9bd5be2b635d9016f1">terminate</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Inverse of method initialize. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="5dbd23c83603b3b09dffa7982112cc95"></a><!-- doxytag: member="tbb::task_scheduler_init::task_scheduler_init" ref="5dbd23c83603b3b09dffa7982112cc95" args="(int number_of_threads=automatic, stack_size_type thread_stack_size=0, bool wait_workers_in_terminate=false) task_scheduler_init(int number_of_threads" -->
&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00355.html#5dbd23c83603b3b09dffa7982112cc95">task_scheduler_init</a> (int number_of_threads=<a class="el" href="a00355.html#8f5988e2b0fbb2d533fcbb7f2583743f">automatic</a>, stack_size_type thread_stack_size=0, bool wait_workers_in_terminate=false) <a class="el" href="a00355.html">task_scheduler_init</a>(int number_of_threads</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Shorthand for default constructor followed by call to initialize(number_of_threads). <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="12752282977029f23416642bc03e8b74"></a><!-- doxytag: member="tbb::task_scheduler_init::is_active" ref="12752282977029f23416642bc03e8b74" args="() const " -->
bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00355.html#12752282977029f23416642bc03e8b74">is_active</a> () const </td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true if scheduler is active (initialized); false otherwise. <br></td></tr>
<tr><td colspan="2"><br><h2>Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">stack_size_type&nbsp;</td><td class="memItemRight" valign="bottom"><b>thread_stack_size</b></td></tr>
<tr><td colspan="2"><br><h2>Static Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="8f5988e2b0fbb2d533fcbb7f2583743f"></a><!-- doxytag: member="tbb::task_scheduler_init::automatic" ref="8f5988e2b0fbb2d533fcbb7f2583743f" args="" -->
static const int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00355.html#8f5988e2b0fbb2d533fcbb7f2583743f">automatic</a> = -1</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Typedef for number of threads that is automatic. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="e6c860f1e559026ff3ef4599c0d6c514"></a><!-- doxytag: member="tbb::task_scheduler_init::deferred" ref="e6c860f1e559026ff3ef4599c0d6c514" args="" -->
static const int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00355.html#e6c860f1e559026ff3ef4599c0d6c514">deferred</a> = -2</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Argument to <a class="el" href="a00355.html#d476053cc712e572554823492a5229ce">initialize()</a> or constructor that causes initialization to be deferred. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Class delimiting the scope of task scheduler activity.
<p>
A thread can construct a <a class="el" href="a00355.html">task_scheduler_init</a> object and keep it alive while it uses TBB's tasking subsystem (including parallel algorithms).<p>
This class allows to customize properties of the TBB task pool to some extent. For example it can limit concurrency level of parallel work initiated by the given thread. It also can be used to specify stack size of the TBB worker threads, though this setting is not effective if the thread pool has already been created.<p>
If a parallel construct is used without <a class="el" href="a00355.html">task_scheduler_init</a> object previously created, the scheduler will be initialized automatically with default settings, and will persist until this thread exits. Default concurrency level is defined as described in <a class="el" href="a00355.html#d476053cc712e572554823492a5229ce">task_scheduler_init::initialize()</a>.
<p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="d5ed214a8bb53b0466ed91ff4734b9a3"></a><!-- doxytag: member="tbb::task_scheduler_init::initialize" ref="d5ed214a8bb53b0466ed91ff4734b9a3" args="(int number_of_threads, stack_size_type thread_stack_size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void __TBB_EXPORTED_METHOD tbb::task_scheduler_init::initialize </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>number_of_threads</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">stack_size_type&nbsp;</td>
<td class="paramname"> <em>thread_stack_size</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
The overloaded method with stack size parameter.
<p>
Overloading is necessary to preserve ABI compatibility
</div>
</div><p>
<a class="anchor" name="d476053cc712e572554823492a5229ce"></a><!-- doxytag: member="tbb::task_scheduler_init::initialize" ref="d476053cc712e572554823492a5229ce" args="(int number_of_threads=automatic)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void __TBB_EXPORTED_METHOD tbb::task_scheduler_init::initialize </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>number_of_threads</em> = <code><a class="el" href="a00355.html#8f5988e2b0fbb2d533fcbb7f2583743f">automatic</a></code> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Ensure that scheduler exists for this thread.
<p>
A value of -1 lets TBB decide on the number of threads, which is usually maximal hardware concurrency for this process, that is the number of logical CPUs on the machine (possibly limited by the processor affinity mask of this process (Windows) or of this thread (Linux, FreeBSD). It is preferable option for production code because it helps to avoid nasty surprises when several TBB based components run side-by-side or in a nested fashion inside the same process.<p>
The number_of_threads is ignored if any other task_scheduler_inits currently exist. A thread may construct multiple task_scheduler_inits. Doing so does no harm because the underlying scheduler is reference counted.
</div>
</div><p>
<hr><h2>Member Data Documentation</h2>
<a class="anchor" name="474d030bbceb4929ca7084eeab598f2b"></a><!-- doxytag: member="tbb::task_scheduler_init::thread_stack_size" ref="474d030bbceb4929ca7084eeab598f2b" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">stack_size_type tbb::task_scheduler_init::thread_stack_size </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<b>Initial value:</b><div class="fragment"><pre class="fragment">0 )
#endif
: my_scheduler(NULL) {
__TBB_ASSERT( !(thread_stack_size &amp; propagation_mode_mask), <span class="stringliteral">"Requested stack size is not aligned"</span> );
<span class="preprocessor">#if TBB_USE_EXCEPTIONS</span>
<span class="preprocessor"></span> thread_stack_size |= TBB_USE_CAPTURED_EXCEPTION ? propagation_mode_captured : propagation_mode_exact;
<span class="preprocessor">#endif </span>
<span class="preprocessor"></span><span class="preprocessor">#if __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE</span>
<span class="preprocessor"></span> <span class="keywordflow">if</span> (wait_workers_in_terminate)
my_scheduler = (internal::scheduler*)wait_workers_in_terminate_flag;
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span> <a class="code" href="a00355.html#d476053cc712e572554823492a5229ce">initialize</a>( number_of_threads, thread_stack_size );
}
~<a class="code" href="a00355.html#5dbd23c83603b3b09dffa7982112cc95">task_scheduler_init</a>() {
<span class="keywordflow">if</span>( my_scheduler )
<a class="code" href="a00355.html#f73257e04cb7fb9bd5be2b635d9016f1">terminate</a>();
internal::poison_pointer( my_scheduler );
}
<span class="keyword">static</span> <span class="keywordtype">int</span> __TBB_EXPORTED_FUNC default_num_threads ()
</pre></div>
</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>task_scheduler_init.h</ul>
<hr>
<p></p>
Copyright &copy; 2005-2013 Intel Corporation. All Rights Reserved.
<p></p>
Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are
registered trademarks or trademarks of Intel Corporation or its
subsidiaries in the United States and other countries.
<p></p>
* Other names and brands may be claimed as the property of others.