summaryrefslogtreecommitdiff
path: root/doc/html/thread/parallel.html
blob: 36eccfce2b9a0fcff6399971eb5a37483ccb1eae (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Parallel - Fork-Join -- EXPERIMENTAL</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../thread.html" title="Chapter&#160;33.&#160;Thread 4.7.0">
<link rel="prev" href="sds.html" title="Synchronized Data Structures">
<link rel="next" href="time.html" title="Time Requirements">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sds.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="time.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="thread.parallel"></a><a class="link" href="parallel.html" title="Parallel - Fork-Join -- EXPERIMENTAL">Parallel - Fork-Join -- EXPERIMENTAL</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join">Fork-Join</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.ref">Reference -- EXPERIMENTAL</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="thread.parallel.fork_join"></a><a class="link" href="parallel.html#thread.parallel.fork_join" title="Fork-Join">Fork-Join</a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.tutorial">Tutorial</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.examples">Examples</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.rationale">Design Rationale</a></span></dt>
</dl></div>
<div class="warning"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../doc/src/images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>
          These features are experimental and subject to change in future versions.
          There are not too much tests yet, so it is possible that you can find out
          some trivial bugs :(
        </p></td></tr>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
          These features are based on the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4088.pdf" target="_top"><span class="bold"><strong>n4088 - Task Region R3</strong></span></a> C++1y proposal from
          P. Halpern, A. Robison, A. Laksberg, H. Sutter, et al. The text that follows
          has been adapted from this paper to show the differences.
        </p></td></tr>
</table></div>
<p>
        The major difference respect to the standard proposal is that we are able
        to use a common executor for several task regions.
      </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
          Up to now, Boost.Thread doesn't implement the parallel algorithms as defined
          in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4105.pdf" target="_top"><span class="bold"><strong>n4105 - Information technology &#8211; Programming languages, their
          environments and system software interfaces &#8211; Technical Specification
          for C++ Extensions for Parallelism</strong></span></a>.
        </p></td></tr>
</table></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="thread.parallel.fork_join.introduction"></a><a class="link" href="parallel.html#thread.parallel.fork_join.introduction" title="Introduction">Introduction</a>
</h4></div></div></div>
<p>
          This module introduces a C++11/c++14 library function template <code class="computeroutput"><span class="identifier">task_region</span></code> and a library class <code class="computeroutput"><span class="identifier">task_region_handle</span></code> with member functions
          <code class="computeroutput"><span class="identifier">run</span></code> and <code class="computeroutput"><span class="identifier">wait</span></code>
          that together enable developers to write expressive and portable fork-join
          parallel code.
        </p>
<p>
          The working draft for the Parallelism TS <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4105.pdf" target="_top"><span class="bold"><strong>N4105</strong></span></a> augments the STL algorithms with the
          inclusion of parallel execution policies. Programmers use these as a basis
          to write additional high-level algorithms that can be implemented in terms
          of the provided parallel algorithms. However, the scope of n4105 does not
          include lower-level mechanisms to express arbitrary fork-join parallelism
        </p>
<p>
          The <code class="computeroutput"><span class="identifier">task_region</span></code>, <code class="computeroutput"><span class="identifier">run</span></code> and the <code class="computeroutput"><span class="identifier">wait</span></code>
          functions provided by this library are based on the <code class="computeroutput"><span class="identifier">task_group</span></code>
          concept that is a part of the common subset of the PPL and the TBB libraries.
        </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="thread.parallel.fork_join.tutorial"></a><a class="link" href="parallel.html#thread.parallel.fork_join.tutorial" title="Tutorial">Tutorial</a>
</h4></div></div></div>
<p>
          Consider an example of a parallel traversal of a tree, where a user-provided
          function compute is applied to each node of the tree, returning the sum
          of the results:
        </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Func</span><span class="special">&gt;</span>
<span class="keyword">int</span> <span class="identifier">traverse</span><span class="special">(</span><span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">,</span> <span class="identifier">Func</span><span class="special">&amp;&amp;</span> <span class="identifier">compute</span><span class="special">)</span>
<span class="special">{</span>
  <span class="keyword">int</span> <span class="identifier">left</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">right</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
  <span class="identifier">task_region</span><span class="special">([&amp;](</span><span class="identifier">task_region_handle</span><span class="special">&amp;</span> <span class="identifier">tr</span><span class="special">)</span> <span class="special">{</span>
    <span class="keyword">if</span> <span class="special">(</span><span class="identifier">n</span><span class="special">-&gt;</span><span class="identifier">left</span><span class="special">)</span>
      <span class="identifier">tr</span><span class="special">.</span><span class="identifier">run</span><span class="special">([&amp;]</span> <span class="special">{</span> <span class="identifier">left</span> <span class="special">=</span> <span class="identifier">traverse</span><span class="special">(</span><span class="identifier">n</span><span class="special">-&gt;</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">compute</span><span class="special">);</span> <span class="special">});</span>
    <span class="keyword">if</span> <span class="special">(</span><span class="identifier">n</span><span class="special">-&gt;</span><span class="identifier">right</span><span class="special">)</span>
      <span class="identifier">tr</span><span class="special">.</span><span class="identifier">run</span><span class="special">([&amp;]</span> <span class="special">{</span> <span class="identifier">right</span> <span class="special">=</span> <span class="identifier">traverse</span><span class="special">(</span><span class="identifier">n</span><span class="special">-&gt;</span><span class="identifier">right</span><span class="special">,</span> <span class="identifier">compute</span><span class="special">);</span> <span class="special">});</span>
  <span class="special">});</span>
  <span class="keyword">return</span> <span class="identifier">compute</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">+</span> <span class="identifier">left</span> <span class="special">+</span> <span class="identifier">right</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
          The example above demonstrates the use of two of the functions proposed
          in this paper, <code class="computeroutput"><span class="identifier">task_region</span></code>
          and <code class="computeroutput"><span class="identifier">task_region_handle</span><span class="special">::</span><span class="identifier">run</span></code>.
          The <code class="computeroutput"><span class="identifier">task_region</span></code> function
          delineates a region in a program code potentially containing invocations
          of tasks spawned by the <code class="computeroutput"><span class="identifier">run</span></code>
          member function of the <code class="computeroutput"><span class="identifier">task_region_handle</span></code>
          class.
        </p>
<p>
          The run function spawns a task, a unit of work that is allowed to execute
          in parallel with respect to the caller. Any parallel tasks spawned by
          <code class="computeroutput"><span class="identifier">run</span></code> within the <code class="computeroutput"><span class="identifier">task_region</span></code> are joined back to a single
          thread of execution at the end of the <code class="computeroutput"><span class="identifier">task_region</span></code>.
        </p>
<p>
          <code class="computeroutput"><span class="identifier">run</span></code> takes a user-provided
          function object <code class="computeroutput"><span class="identifier">f</span></code> and starts
          it asynchronously - i.e. it may return before the execution of <code class="computeroutput"><span class="identifier">f</span></code> completes. The implementation's scheduler
          may choose to run <code class="computeroutput"><span class="identifier">f</span></code> immediately
          or delay running <code class="computeroutput"><span class="identifier">f</span></code> until
          compute resources become available.
        </p>
<p>
          A <code class="computeroutput"><span class="identifier">task_region_handle</span></code> can
          be constructed only by <code class="computeroutput"><span class="identifier">task_region</span></code>
          because it has no public constructors. Thus, <code class="computeroutput"><span class="identifier">run</span></code>
          can be invoked (directly or indirectly) only from a user-provided function
          passed to <code class="computeroutput"><span class="identifier">task_region</span></code>:
        </p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">g</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">task_region_handle</span><span class="special">&amp;</span> <span class="identifier">tr</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">tr</span><span class="special">.</span><span class="identifier">run</span><span class="special">(</span><span class="identifier">g</span><span class="special">);</span> <span class="comment">// OK, invoked from within task_region in h</span>
<span class="special">}</span>
<span class="keyword">void</span> <span class="identifier">h</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">task_region</span><span class="special">(</span><span class="identifier">f</span><span class="special">);</span>
<span class="special">}</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">task_region_handle</span> <span class="identifier">tr</span><span class="special">;</span> <span class="comment">// Error: no public constructor</span>
  <span class="identifier">tr</span><span class="special">.</span><span class="identifier">run</span><span class="special">(</span><span class="identifier">g</span><span class="special">);</span> <span class="comment">// No way to call run outside of a task_region</span>
  <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="thread.parallel.fork_join.examples"></a><a class="link" href="parallel.html#thread.parallel.fork_join.examples" title="Examples">Examples</a>
</h4></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.examples.fib">Parallel
          Fibonacci</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.examples.fibex">Parallel
          Fibonacci - Specific executor</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.examples.quick_sort">Parallel
          Accumulate</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.fork_join.examples.quick_sort0">Parallel
          Quick Sort</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="thread.parallel.fork_join.examples.fib"></a><a class="link" href="parallel.html#thread.parallel.fork_join.examples.fib" title="Parallel Fibonacci">Parallel
          Fibonacci</a>
</h5></div></div></div>
<p>
            This is surely the worst implementation of the Fibonacci function. Anyway,
            here it is, as it is simple and shows the fork-join structure clearly.
            <code class="computeroutput"><span class="identifier">Fibonacci</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">Fibonacci</span><span class="special">(</span><span class="identifier">n</span><span class="special">-</span><span class="number">1</span><span class="special">)</span>
            <span class="special">+</span> <span class="identifier">Fibonacci</span><span class="special">(</span><span class="identifier">n</span><span class="special">-</span><span class="number">2</span><span class="special">)</span></code>,
            so the task decomposition is trivial.
          </p>
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">fib_task_region</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
<span class="special">{</span>
  <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">parallel</span><span class="special">::</span><span class="identifier">task_region</span><span class="special">;</span>
  <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">parallel</span><span class="special">::</span><span class="identifier">task_region_handle</span><span class="special">;</span>

  <span class="keyword">if</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
  <span class="keyword">if</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span>

  <span class="keyword">int</span> <span class="identifier">n1</span><span class="special">;</span>
  <span class="keyword">int</span> <span class="identifier">n2</span><span class="special">;</span>

  <span class="identifier">task_region</span><span class="special">([&amp;](</span><span class="identifier">task_region_handle</span><span class="special">&amp;</span> <span class="identifier">trh</span><span class="special">)</span>
      <span class="special">{</span>
        <span class="identifier">trh</span><span class="special">.</span><span class="identifier">run</span><span class="special">([&amp;]</span>
            <span class="special">{</span>
              <span class="identifier">n1</span> <span class="special">=</span> <span class="identifier">fib_task_region</span><span class="special">(</span><span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
            <span class="special">});</span>

        <span class="identifier">n2</span> <span class="special">=</span> <span class="identifier">fib_task_region</span><span class="special">(</span><span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">);</span>
      <span class="special">});</span>

  <span class="keyword">return</span> <span class="identifier">n1</span> <span class="special">+</span> <span class="identifier">n2</span><span class="special">;</span>
<span class="special">}</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
  <span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">10</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">fib_task_region</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span><span class="special">;</span>
  <span class="special">}</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="thread.parallel.fork_join.examples.fibex"></a><a class="link" href="parallel.html#thread.parallel.fork_join.examples.fibex" title="Parallel Fibonacci - Specific executor">Parallel
          Fibonacci - Specific executor</a>
</h5></div></div></div>
<p>
            The previous example make use of an implementation defined way to spawn
            the tasks. Often the user wants to master how the task must be spawned.
            There is an overload of <code class="computeroutput"><span class="identifier">task_region</span></code>
            that accept an additional <code class="computeroutput"><span class="identifier">Executor</span></code>
            parameter and a function that takes as parameter a <code class="computeroutput"><span class="identifier">task_region_handle_gen</span><span class="special">&lt;</span><span class="identifier">Executor</span><span class="special">&gt;</span></code>. <code class="computeroutput"><span class="identifier">task_region_handle_gen</span><span class="special">&lt;</span><span class="identifier">Executor</span><span class="special">&gt;</span></code> run uses this executor to spawn the
            tasks.
          </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Ex</span><span class="special">&gt;</span>
<span class="keyword">int</span> <span class="identifier">fib_task_region_gen</span><span class="special">(</span> <span class="identifier">Ex</span><span class="special">&amp;</span> <span class="identifier">ex</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span>
<span class="special">{</span>
  <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">parallel</span><span class="special">::</span><span class="identifier">task_region</span><span class="special">;</span>
  <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">experimental</span><span class="special">::</span><span class="identifier">parallel</span><span class="special">::</span><span class="identifier">task_region_handle_gen</span><span class="special">;</span>

  <span class="keyword">if</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
  <span class="keyword">if</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span>

  <span class="keyword">int</span> <span class="identifier">n1</span><span class="special">;</span>
  <span class="keyword">int</span> <span class="identifier">n2</span><span class="special">;</span>

  <span class="identifier">task_region</span><span class="special">(</span><span class="identifier">ex</span><span class="special">,</span> <span class="special">[&amp;](</span><span class="identifier">task_region_handle_gen</span><span class="special">&lt;</span><span class="identifier">Ex</span><span class="special">&gt;&amp;</span> <span class="identifier">trh</span><span class="special">)</span> <span class="comment">// (2)</span>
      <span class="special">{</span>
        <span class="identifier">trh</span><span class="special">.</span><span class="identifier">run</span><span class="special">([&amp;]</span>
            <span class="special">{</span>
              <span class="identifier">n1</span> <span class="special">=</span> <span class="identifier">fib_task_region</span><span class="special">(</span><span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
            <span class="special">});</span>

        <span class="identifier">n2</span> <span class="special">=</span> <span class="identifier">fib_task_region</span><span class="special">(</span><span class="identifier">n</span> <span class="special">-</span> <span class="number">2</span><span class="special">);</span>
      <span class="special">});</span>

  <span class="keyword">return</span> <span class="identifier">n1</span> <span class="special">+</span> <span class="identifier">n2</span><span class="special">;</span>
<span class="special">}</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">boost</span><span class="special">::</span><span class="identifier">basic_thread_pool</span> <span class="identifier">tp</span><span class="special">;</span> <span class="comment">// (1)</span>
  <span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">10</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">fib_task_region_gen</span><span class="special">(</span><span class="identifier">tp</span><span class="special">,</span><span class="identifier">i</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span><span class="special">;</span>
  <span class="special">}</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
  <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
            The specific executor is declared in line (1) and it is used in line
            (2).
          </p>
</div>
<div class="section"><div class="titlepage"><div><div><h5 class="title">
<a name="thread.parallel.fork_join.examples.quick_sort"></a><a class="link" href="parallel.html#thread.parallel.fork_join.examples.quick_sort" title="Parallel Accumulate">Parallel
          Accumulate</a>
</h5></div></div></div></div>
<div class="section"><div class="titlepage"><div><div><h5 class="title">
<a name="thread.parallel.fork_join.examples.quick_sort0"></a><a class="link" href="parallel.html#thread.parallel.fork_join.examples.quick_sort0" title="Parallel Quick Sort">Parallel
          Quick Sort</a>
</h5></div></div></div></div>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title">
<a name="thread.parallel.fork_join.rationale"></a><a class="link" href="parallel.html#thread.parallel.fork_join.rationale" title="Design Rationale">Design Rationale</a>
</h4></div></div></div></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="thread.parallel.ref"></a><a class="link" href="parallel.html#thread.parallel.ref" title="Reference -- EXPERIMENTAL">Reference -- EXPERIMENTAL</a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="parallel.html#thread.parallel.ref.v1">Parallel V1</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.ref.v2">Parallel V2</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="thread.parallel.ref.v1"></a><a class="link" href="parallel.html#thread.parallel.ref.v1" title="Parallel V1">Parallel V1</a>
</h4></div></div></div>
<div class="toc"><dl><dt><span class="section"><a href="parallel.html#thread.parallel.ref.v1.exception_list">Header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">experimental</span><span class="special">/</span><span class="identifier">exception_list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code></a></span></dt></dl></div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="thread.parallel.ref.v1.exception_list"></a><a class="link" href="parallel.html#thread.parallel.ref.v1.exception_list" title="Header &lt;experimental/exception_list.hpp&gt;">Header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">experimental</span><span class="special">/</span><span class="identifier">exception_list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code></a>
</h5></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v1</span>
<span class="special">{</span>

  <span class="keyword">class</span> <span class="identifier">exception_list</span><span class="special">;</span>

<span class="special">}</span> <span class="comment">// v1</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v1.exception_list.exception_list"></a><a class="link" href="parallel.html#thread.parallel.ref.v1.exception_list.exception_list" title="Class exception_list">Class
            <code class="computeroutput"><span class="identifier">exception_list</span></code></a>
</h6></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v1</span>
<span class="special">{</span>

  <span class="keyword">class</span> <span class="identifier">exception_list</span><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span>
  <span class="special">{</span>
  <span class="keyword">public</span><span class="special">:</span>
    <span class="keyword">typedef</span> <span class="char">'implementation defined'</span> <span class="identifier">const_iterator</span><span class="special">;</span>

    <span class="special">~</span><span class="identifier">exception_list</span><span class="special">()</span> <span class="keyword">noexcept</span> <span class="special">{}</span>

    <span class="keyword">void</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">exception_ptr</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">);</span>
    <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
    <span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
    <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
    <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">what</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="special">};</span>

<span class="special">}</span> <span class="comment">// v1</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
</div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="thread.parallel.ref.v2"></a><a class="link" href="parallel.html#thread.parallel.ref.v2" title="Parallel V2">Parallel V2</a>
</h4></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="parallel.html#thread.parallel.ref.v2.concepts">Concepts</a></span></dt>
<dt><span class="section"><a href="parallel.html#thread.parallel.ref.v2.task_region">Header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">experimental</span><span class="special">/</span><span class="identifier">task_region</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code></a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="thread.parallel.ref.v2.concepts"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.concepts" title="Concepts">Concepts</a>
</h5></div></div></div>
<div class="section"><div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.concepts.regionCallable"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.concepts.regionCallable" title="Concept Region_Callable">Concept
            <code class="computeroutput"><span class="identifier">Region_Callable</span></code></a>
</h6></div></div></div></div>
<div class="section"><div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.concepts.taskCallable"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.concepts.taskCallable" title="Concept Task_Callable">Concept
            <code class="computeroutput"><span class="identifier">Task_Callable</span></code></a>
</h6></div></div></div></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="thread.parallel.ref.v2.task_region"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.task_region" title="Header &lt;experimental/task_region.hpp&gt;">Header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">experimental</span><span class="special">/</span><span class="identifier">task_region</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code></a>
</h5></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v2</span>
<span class="special">{</span>

  <span class="keyword">class</span> <span class="identifier">task_canceled_exception</span><span class="special">;</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Executor</span><span class="special">&gt;</span>
  <span class="keyword">class</span> <span class="identifier">task_region_handle_gen</span><span class="special">;</span>

  <span class="keyword">using</span> <span class="identifier">default_executor</span> <span class="special">=</span> <span class="char">'implementation defined'</span><span class="special">;</span>

  <span class="keyword">class</span> <span class="identifier">task_region_handle</span><span class="special">;</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Executor</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region_final</span><span class="special">(</span><span class="identifier">Executor</span><span class="special">&amp;</span> <span class="identifier">ex</span><span class="special">,</span> <span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region_final</span><span class="special">(</span><span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Executor</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region</span><span class="special">(</span><span class="identifier">Executor</span><span class="special">&amp;</span> <span class="identifier">ex</span><span class="special">,</span> <span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region</span><span class="special">(</span><span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>

<span class="special">}</span> <span class="comment">// v2</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.task_region.task_canceled_exception"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.task_region.task_canceled_exception" title="Class task_canceled_exception">Class
            <code class="computeroutput"><span class="identifier">task_canceled_exception</span> </code></a>
</h6></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v2</span>
<span class="special">{</span>

  <span class="keyword">class</span> <span class="identifier">task_canceled_exception</span><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span>
  <span class="special">{</span>
  <span class="keyword">public</span><span class="special">:</span>
    <span class="identifier">task_canceled_exception</span><span class="special">()</span> <span class="keyword">noexcept</span><span class="special">;</span>
    <span class="identifier">task_canceled_exception</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">task_canceled_exception</span><span class="special">&amp;)</span> <span class="keyword">noexcept</span><span class="special">;</span>
    <span class="identifier">task_canceled_exception</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">task_canceled_exception</span><span class="special">&amp;)</span> <span class="keyword">noexcept</span><span class="special">;</span>
    <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">what</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="special">};</span>

<span class="special">}</span> <span class="comment">// v2</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.task_region.task_region_handle_gen"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.task_region.task_region_handle_gen" title="Template Class task_region_handle_gen&lt;&gt;">Template
            Class <code class="computeroutput"><span class="identifier">task_region_handle_gen</span><span class="special">&lt;&gt;</span></code></a>
</h6></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v2</span>
<span class="special">{</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Executor</span><span class="special">&gt;</span>
  <span class="keyword">class</span> <span class="identifier">task_region_handle_gen</span>
  <span class="special">{</span>
  <span class="keyword">protected</span><span class="special">:</span>
    <span class="identifier">task_region_handle_gen</span><span class="special">(</span><span class="identifier">Executor</span><span class="special">&amp;</span> <span class="identifier">ex</span><span class="special">);</span>

    <span class="special">~</span><span class="identifier">task_region_handle_gen</span><span class="special">();</span>

  <span class="keyword">public</span><span class="special">:</span>
    <span class="identifier">task_region_handle_gen</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">task_region_handle_gen</span><span class="special">&amp;)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
    <span class="identifier">task_region_handle_gen</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">task_region_handle_gen</span><span class="special">&amp;)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
    <span class="identifier">task_region_handle_gen</span><span class="special">*</span> <span class="keyword">operator</span><span class="special">&amp;()</span> <span class="keyword">const</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>

    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">run</span><span class="special">(</span><span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>

    <span class="keyword">void</span> <span class="identifier">wait</span><span class="special">();</span>
  <span class="special">};</span>

<span class="special">}</span> <span class="comment">// v2</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.task_region.default_executor"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.task_region.default_executor" title="Class default_executor">Class
            <code class="computeroutput"><span class="identifier">default_executor</span> </code></a>
</h6></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v2</span>
<span class="special">{</span>

  <span class="keyword">using</span> <span class="identifier">default_executor</span> <span class="special">=</span> <span class="char">'implementation defined'</span><span class="special">;</span>

<span class="special">}</span> <span class="comment">// v2</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.task_region.task_region_handle"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.task_region.task_region_handle" title="Class task_region_handle">Class
            <code class="computeroutput"><span class="identifier">task_region_handle</span> </code></a>
</h6></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v2</span>
<span class="special">{</span>

  <span class="keyword">class</span> <span class="identifier">task_region_handle</span> <span class="special">:</span>
    <span class="keyword">public</span> <span class="identifier">task_region_handle_gen</span><span class="special">&lt;</span><span class="identifier">default_executor</span><span class="special">&gt;</span>
  <span class="special">{</span>
  <span class="keyword">protected</span><span class="special">:</span>
    <span class="identifier">task_region_handle</span><span class="special">();</span>
    <span class="identifier">task_region_handle</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">task_region_handle</span><span class="special">&amp;)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
    <span class="identifier">task_region_handle</span><span class="special">&amp;</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">task_region_handle</span><span class="special">&amp;)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
    <span class="identifier">task_region_handle</span><span class="special">*</span> <span class="keyword">operator</span><span class="special">&amp;()</span> <span class="keyword">const</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>

  <span class="special">};</span>

<span class="special">}</span> <span class="comment">// v2</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.task_region.task_region_final"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.task_region.task_region_final" title="Template Function task_region_final">Template
            Function <code class="computeroutput"><span class="identifier">task_region_final</span>
            </code></a>
</h6></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v2</span>
<span class="special">{</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Executor</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region_final</span><span class="special">(</span><span class="identifier">Executor</span><span class="special">&amp;</span> <span class="identifier">ex</span><span class="special">,</span> <span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region_final</span><span class="special">(</span><span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>

<span class="special">}</span> <span class="comment">// v2</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="thread.parallel.ref.v2.task_region.task_region"></a><a class="link" href="parallel.html#thread.parallel.ref.v2.task_region.task_region" title="Template Function task_region">Template
            Function <code class="computeroutput"><span class="identifier">task_region</span> </code></a>
</h6></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">experimental</span>
<span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">parallel</span>
<span class="special">{</span>
<span class="keyword">inline</span> <span class="keyword">namespace</span> <span class="identifier">v2</span>
<span class="special">{</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Executor</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region</span><span class="special">(</span><span class="identifier">Executor</span><span class="special">&amp;</span> <span class="identifier">ex</span><span class="special">,</span> <span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">F</span><span class="special">&gt;</span>
    <span class="keyword">void</span> <span class="identifier">task_region</span><span class="special">(</span><span class="identifier">F</span><span class="special">&amp;&amp;</span> <span class="identifier">f</span><span class="special">);</span>

<span class="special">}</span> <span class="comment">// v2</span>
<span class="special">}</span> <span class="comment">// parallel</span>
<span class="special">}</span> <span class="comment">// experimental</span>
<span class="special">}</span> <span class="comment">// boost</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2007 -11 Anthony Williams<br>Copyright &#169; 2011 -15 Vicente J. Botet Escriba<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sds.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../thread.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="time.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>