1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="DC.Type" content="reference">
<meta name="DC.Title" content="structured_task_group Class">
<meta name="DC.subject" content="structured_task_group Class">
<meta name="keywords" content="structured_task_group Class">
<meta name="DC.Relation" scheme="URI" content="../../reference/task_groups.htm">
<meta name="DC.Relation" scheme="URI" content="task_handle_cls.htm">
<meta name="DC.Relation" scheme="URI" content="task_group_cls.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="structured_task_group_cls">
<meta name="DC.Language" content="en-US">
<link rel="stylesheet" type="text/css" href="../../intel_css_styles.css">
<title>structured_task_group Class</title>
</head>
<body id="structured_task_group_cls">
<!-- ==============(Start:NavScript)================= -->
<script src="..\..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
<script language="JavaScript1.2" type="text/javascript">WriteNavLink(2);</script>
<!-- ==============(End:NavScript)================= -->
<a name="structured_task_group_cls"><!-- --></a>
<h1 class="topictitle1">structured_task_group Class</h1>
<div><div class="section"><h2 class="sectiontitle">Description</h2>
<p>A <samp class="codeph">structured_task_group</samp> is like a <samp class="codeph">task_group</samp>, but has only a subset of the functionality. It may permit performance optimizations in the future. The restrictions are:</p>
<ul type="disc" class="ul_3">
<li class="li_2">Methods <samp class="codeph">run</samp> and <samp class="codeph">run_and_wait</samp> take only <samp class="codeph">task_handle</samp> arguments, not general functors.</li>
<li class="li_2">Methods <samp class="codeph">run</samp> and
<samp class="codeph">run_and_wait</samp> do not copy their <samp class="codeph">task_handle</samp>
arguments. The caller must not destroy those arguments until after wait
or<samp class="codeph"> run_</samp>and<samp class="codeph">_wait</samp> returns.</li>
<li class="li_2">Methods <samp class="codeph">run</samp>, <samp class="codeph">run_and_wait</samp>, <samp class="codeph">cancel</samp>, and <samp class="codeph">wait</samp> should be called only by the thread that created the <samp class="codeph">structured_task_group</samp>.</li>
<li class="li_2">Method <samp class="codeph">wait</samp> (or <samp class="codeph">run_and_wait</samp>) should be called only once on a given instance of <samp class="codeph">structured_task_group</samp>.</li>
</ul>
</div>
<div class="section"><h2 class="sectiontitle">Example</h2>
<p>The function <samp class="codeph">fork_join</samp> below evaluates <samp class="codeph">f1()</samp> and <samp class="codeph">f2()</samp>, in parallel if resources permit.</p>
<pre> #include "tbb/task_group.h"
using namespace tbb;
template<typename Func1, typename Func2>
void fork_join( const Func1& f1, const Func2& f2 ) {
structured_task_group group;
task_handle<Func1> h1(f1);
group.run(h1); // spawn a task
task_handle<Func2> h2(f2);
group.run(h2); // spawn another task
group.wait(); // wait for both tasks to complete
// now safe to destroy h1 and h2
}</pre>
</div>
<div class="section"><h2 class="sectiontitle">Members</h2>
<pre> namespace tbb {
class structured_task_group {
public:
structured_task_group();
~structured_task_group();
template<typename Func>
void run( task_handle<Func>& handle );
template<typename Func>
void run_and_wait( task_handle<Func>& handle );
task_group_status wait();
bool is_canceling();
void cancel();
};
}
</pre></div>
</div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="../../reference/task_groups.htm">Task Groups</a></div>
</div>
<div class="See Also">
<h2>See Also</h2>
<div class="linklist">
<div><a href="task_handle_cls.htm">task_handle Template Class</a></div>
<div><a href="task_group_cls.htm">task_group Class</a></div></div>
</div>
</body>
</html>
|