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

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.