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 #ifndef __TBB_combinable_H
18 #define __TBB_combinable_H
19 
20 #define __TBB_combinable_H_include_area
22 
25 
26 namespace tbb {
30 
32  template <typename T>
33  class combinable {
34 
35  private:
38  my_ets_type my_ets;
39 
40  public:
41 
42  combinable() { }
43 
44  template <typename finit>
45  explicit combinable( finit _finit) : my_ets(_finit) { }
46 
49 
50  combinable( const combinable& other) : my_ets(other.my_ets) { }
51 
52 #if __TBB_ETS_USE_CPP11
53  combinable( combinable&& other) : my_ets( std::move(other.my_ets)) { }
54 #endif
55 
56  combinable & operator=( const combinable & other) {
57  my_ets = other.my_ets;
58  return *this;
59  }
60 
61 #if __TBB_ETS_USE_CPP11
63  my_ets=std::move(other.my_ets);
64  return *this;
65  }
66 #endif
67 
68  void clear() { my_ets.clear(); }
69 
70  T& local() { return my_ets.local(); }
71 
72  T& local(bool & exists) { return my_ets.local(exists); }
73 
74  // combine_func_t has signature T(T,T) or T(const T&, const T&)
75  template <typename combine_func_t>
76  T combine(combine_func_t f_combine) { return my_ets.combine(f_combine); }
77 
78  // combine_func_t has signature void(T) or void(const T&)
79  template <typename combine_func_t>
80  void combine_each(combine_func_t f_combine) { my_ets.combine_each(f_combine); }
81 
82  };
83 } // namespace tbb
84 
86 #undef __TBB_combinable_H_include_area
87 
88 #endif /* __TBB_combinable_H */
void move(tbb_thread &t1, tbb_thread &t2)
Definition: tbb_thread.h:319
Thread-local storage with optional reduction.
Definition: combinable.h:33
combinable & operator=(const combinable &other)
Definition: combinable.h:56
combinable & operator=(combinable &&other)
Definition: combinable.h:62
~combinable()
destructor
Definition: combinable.h:48
reference local()
returns reference to local, discarding exists
combinable(const combinable &other)
Definition: combinable.h:50
The enumerable_thread_specific container.
tbb::enumerable_thread_specific< T, my_alloc, ets_no_key > my_ets_type
Definition: combinable.h:37
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
T & local(bool &exists)
Definition: combinable.h:72
tbb::cache_aligned_allocator< T > my_alloc
Definition: combinable.h:36
T combine(combine_func_t f_combine)
Definition: combinable.h:76
combinable(combinable &&other)
Definition: combinable.h:53
void combine_each(combine_func_t f_combine)
Definition: combinable.h:80
STL namespace.
combinable(finit _finit)
Definition: combinable.h:45
my_ets_type my_ets
Definition: combinable.h:38
The graph class.

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.