Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
combinable.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2019 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 
17 
18 
19 */
20 
21 #ifndef __TBB_combinable_H
22 #define __TBB_combinable_H
23 
26 
27 namespace tbb {
31 
33  template <typename T>
34  class combinable {
35 
36  private:
39  my_ets_type my_ets;
40 
41  public:
42 
43  combinable() { }
44 
45  template <typename finit>
46  explicit combinable( finit _finit) : my_ets(_finit) { }
47 
50 
51  combinable( const combinable& other) : my_ets(other.my_ets) { }
52 
53 #if __TBB_ETS_USE_CPP11
54  combinable( combinable&& other) : my_ets( std::move(other.my_ets)) { }
55 #endif
56 
57  combinable & operator=( const combinable & other) {
58  my_ets = other.my_ets;
59  return *this;
60  }
61 
62 #if __TBB_ETS_USE_CPP11
64  my_ets=std::move(other.my_ets);
65  return *this;
66  }
67 #endif
68 
69  void clear() { my_ets.clear(); }
70 
71  T& local() { return my_ets.local(); }
72 
73  T& local(bool & exists) { return my_ets.local(exists); }
74 
75  // combine_func_t has signature T(T,T) or T(const T&, const T&)
76  template <typename combine_func_t>
77  T combine(combine_func_t f_combine) { return my_ets.combine(f_combine); }
78 
79  // combine_func_t has signature void(T) or void(const T&)
80  template <typename combine_func_t>
81  void combine_each(combine_func_t f_combine) { my_ets.combine_each(f_combine); }
82 
83  };
84 } // namespace tbb
85 #endif /* __TBB_combinable_H */
tbb::cache_aligned_allocator< T > my_alloc
Definition: combinable.h:37
combinable(combinable &&other)
Definition: combinable.h:54
tbb::enumerable_thread_specific< T, my_alloc, ets_no_key > my_ets_type
Definition: combinable.h:38
combinable & operator=(const combinable &other)
Definition: combinable.h:57
my_ets_type my_ets
Definition: combinable.h:39
T & local(bool &exists)
Definition: combinable.h:73
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
The enumerable_thread_specific container.
combinable(const combinable &other)
Definition: combinable.h:51
The graph class.
~combinable()
destructor
Definition: combinable.h:49
void combine_each(combine_func_t f_combine)
Definition: combinable.h:81
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:309
T combine(combine_func_t f_combine)
Definition: combinable.h:77
STL namespace.
combinable(finit _finit)
Definition: combinable.h:46
Thread-local storage with optional reduction.
Definition: combinable.h:34
combinable & operator=(combinable &&other)
Definition: combinable.h:63
reference local()
returns reference to local, discarding exists

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

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.

* Other names and brands may be claimed as the property of others.