File: structured_task_group_cls.htm

package info (click to toggle)
tbb 4.2~20140122-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 21,492 kB
  • ctags: 21,278
  • sloc: cpp: 92,813; ansic: 9,775; asm: 1,070; makefile: 1,057; sh: 351; java: 226; objc: 98; pascal: 71; xml: 41
file content (102 lines) | stat: -rwxr-xr-x 5,499 bytes parent folder | download
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"
    &nbsp;
    using namespace tbb;
    &nbsp;
    template&lt;typename Func1, typename Func2&gt;
    void fork_join( const Func1&amp; f1, const Func2&amp; f2 ) {
    &nbsp;&nbsp;&nbsp; structured_task_group group;
    &nbsp;
    &nbsp;&nbsp;&nbsp; task_handle&lt;Func1&gt; h1(f1);
    &nbsp;&nbsp;&nbsp; group.run(h1);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; // spawn a task
    &nbsp;
    &nbsp;&nbsp;&nbsp; task_handle&lt;Func2&gt; h2(f2);
    &nbsp;&nbsp;  group.run(h2);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; // spawn another task
    &nbsp;
    &nbsp;&nbsp;&nbsp; group.wait();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // wait for both tasks to complete
    &nbsp;&nbsp;&nbsp; // now safe to destroy h1 and h2
    }</pre>
        </div>
<div class="section"><h2 class="sectiontitle">Members</h2>
<pre> namespace tbb {
    &nbsp;&nbsp;&nbsp; class structured_task_group {
    &nbsp;&nbsp;&nbsp; public:
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; structured_task_group();
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ~structured_task_group();
    &nbsp;
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; template&lt;typename Func&gt; 
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void run( task_handle&lt;Func&gt;&amp; handle );
    &nbsp;
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; template&lt;typename Func&gt;
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void run_and_wait( task_handle&lt;Func&gt;&amp; handle );
    &nbsp;
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; task_group_status wait(); 
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; bool is_canceling();
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void cancel();
    &nbsp;&nbsp;&nbsp; };
    }
    &nbsp;</pre></div>
</div>
 
  
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<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>