1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3
<title>parallel_for_each.h Source File</title>
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
<link href="tabs.css" rel="stylesheet" type="text/css">
7
<!-- Generated by Doxygen 1.4.7 -->
10
<li><a href="index.html"><span>Main Page</span></a></li>
11
<li><a href="modules.html"><span>Modules</span></a></li>
12
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
13
<li><a href="annotated.html"><span>Classes</span></a></li>
14
<li id="current"><a href="files.html"><span>Files</span></a></li>
15
<li><a href="pages.html"><span>Related Pages</span></a></li>
19
<li><a href="files.html"><span>File List</span></a></li>
20
<li><a href="globals.html"><span>File Members</span></a></li>
22
<h1>parallel_for_each.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
23
<a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2009 Intel Corporation. All Rights Reserved.</span>
24
<a name="l00003"></a>00003 <span class="comment"></span>
25
<a name="l00004"></a>00004 <span class="comment"> The source code contained or described herein and all documents related</span>
26
<a name="l00005"></a>00005 <span class="comment"> to the source code ("Material") are owned by Intel Corporation or its</span>
27
<a name="l00006"></a>00006 <span class="comment"> suppliers or licensors. Title to the Material remains with Intel</span>
28
<a name="l00007"></a>00007 <span class="comment"> Corporation or its suppliers and licensors. The Material is protected</span>
29
<a name="l00008"></a>00008 <span class="comment"> by worldwide copyright laws and treaty provisions. No part of the</span>
30
<a name="l00009"></a>00009 <span class="comment"> Material may be used, copied, reproduced, modified, published, uploaded,</span>
31
<a name="l00010"></a>00010 <span class="comment"> posted, transmitted, distributed, or disclosed in any way without</span>
32
<a name="l00011"></a>00011 <span class="comment"> Intel's prior express written permission.</span>
33
<a name="l00012"></a>00012 <span class="comment"></span>
34
<a name="l00013"></a>00013 <span class="comment"> No license under any patent, copyright, trade secret or other</span>
35
<a name="l00014"></a>00014 <span class="comment"> intellectual property right is granted to or conferred upon you by</span>
36
<a name="l00015"></a>00015 <span class="comment"> disclosure or delivery of the Materials, either expressly, by</span>
37
<a name="l00016"></a>00016 <span class="comment"> implication, inducement, estoppel or otherwise. Any license under such</span>
38
<a name="l00017"></a>00017 <span class="comment"> intellectual property rights must be express and approved by Intel in</span>
39
<a name="l00018"></a>00018 <span class="comment"> writing.</span>
40
<a name="l00019"></a>00019 <span class="comment">*/</span>
41
<a name="l00020"></a>00020
42
<a name="l00021"></a>00021 <span class="preprocessor">#ifndef __TBB_parallel_for_each_H</span>
43
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define __TBB_parallel_for_each_H</span>
44
<a name="l00023"></a>00023 <span class="preprocessor"></span>
45
<a name="l00024"></a>00024 <span class="preprocessor">#include "parallel_do.h"</span>
46
<a name="l00025"></a>00025
47
<a name="l00026"></a>00026 <span class="keyword">namespace </span>tbb {
48
<a name="l00027"></a>00027
49
<a name="l00029"></a>00029 <span class="keyword">namespace </span>internal {
50
<a name="l00030"></a>00030 <span class="comment">// The class calls user function in operator()</span>
51
<a name="l00031"></a>00031 <span class="keyword">template</span> <<span class="keyword">typename</span> Function, <span class="keyword">typename</span> Iterator>
52
<a name="l00032"></a>00032 <span class="keyword">class </span>parallel_for_each_body : internal::no_assign {
53
<a name="l00033"></a>00033 Function &my_func;
54
<a name="l00034"></a>00034 <span class="keyword">public</span>:
55
<a name="l00035"></a>00035 parallel_for_each_body(Function &_func) : my_func(_func) {}
56
<a name="l00036"></a>00036 parallel_for_each_body(<span class="keyword">const</span> parallel_for_each_body<Function, Iterator> &_caller) : my_func(_caller.my_func) {}
57
<a name="l00037"></a>00037
58
<a name="l00038"></a>00038 <span class="keywordtype">void</span> operator() ( <span class="keyword">typename</span> std::iterator_traits<Iterator>::value_type value )<span class="keyword"> const </span>{
59
<a name="l00039"></a>00039 my_func(value);
60
<a name="l00040"></a>00040 }
61
<a name="l00041"></a>00041 };
62
<a name="l00042"></a>00042 } <span class="comment">// namespace internal</span>
63
<a name="l00044"></a>00044 <span class="comment"></span>
64
<a name="l00048"></a>00048
65
<a name="l00049"></a>00049
66
<a name="l00050"></a>00050 <span class="keyword">template</span><<span class="keyword">typename</span> InputIterator, <span class="keyword">typename</span> Function>
67
<a name="l00051"></a><a class="code" href="a00233.html#gbcb40499f038fd82deca88366b404790">00051</a> Function <a class="code" href="a00233.html#gbcb40499f038fd82deca88366b404790">parallel_for_each</a>(InputIterator first, InputIterator last, Function f, <a class="code" href="a00167.html">task_group_context</a> &context) {
68
<a name="l00052"></a>00052 internal::parallel_for_each_body<Function, InputIterator> body(f);
69
<a name="l00053"></a>00053
70
<a name="l00054"></a>00054 <a class="code" href="a00233.html#g3383e2703977012b6f384d673410f1f7">tbb::parallel_do</a> (first, last, body, context);
71
<a name="l00055"></a>00055 <span class="keywordflow">return</span> f;
72
<a name="l00056"></a>00056 }
73
<a name="l00057"></a>00057
74
<a name="l00059"></a>00059 <span class="keyword">template</span><<span class="keyword">typename</span> InputIterator, <span class="keyword">typename</span> Function>
75
<a name="l00060"></a><a class="code" href="a00233.html#g85a58ff0853f129adb6f9e4355326ccc">00060</a> Function <a class="code" href="a00233.html#gbcb40499f038fd82deca88366b404790">parallel_for_each</a>(InputIterator first, InputIterator last, Function f) {
76
<a name="l00061"></a>00061 internal::parallel_for_each_body<Function, InputIterator> body(f);
77
<a name="l00062"></a>00062
78
<a name="l00063"></a>00063 <a class="code" href="a00233.html#g3383e2703977012b6f384d673410f1f7">tbb::parallel_do</a> (first, last, body);
79
<a name="l00064"></a>00064 <span class="keywordflow">return</span> f;
80
<a name="l00065"></a>00065 }
81
<a name="l00066"></a>00066
82
<a name="l00068"></a>00068
83
<a name="l00069"></a>00069 } <span class="comment">// namespace</span>
84
<a name="l00070"></a>00070
85
<a name="l00071"></a>00071 <span class="preprocessor">#endif </span><span class="comment">/* __TBB_parallel_for_each_H */</span>
88
Copyright © 2005-2009 Intel Corporation. All Rights Reserved.
90
Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are
91
registered trademarks or trademarks of Intel Corporation or its
92
subsidiaries in the United States and other countries.
94
* Other names and brands may be claimed as the property of others.