Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:51

0001 /*
0002     Copyright (c) 2005-2020 Intel Corporation
0003 
0004     Licensed under the Apache License, Version 2.0 (the "License");
0005     you may not use this file except in compliance with the License.
0006     You may obtain a copy of the License at
0007 
0008         http://www.apache.org/licenses/LICENSE-2.0
0009 
0010     Unless required by applicable law or agreed to in writing, software
0011     distributed under the License is distributed on an "AS IS" BASIS,
0012     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013     See the License for the specific language governing permissions and
0014     limitations under the License.
0015 */
0016 
0017 #ifndef __TBB_combinable_H
0018 #define __TBB_combinable_H
0019 
0020 #define __TBB_combinable_H_include_area
0021 #include "internal/_warning_suppress_enable_notice.h"
0022 
0023 #include "enumerable_thread_specific.h"
0024 #include "cache_aligned_allocator.h"
0025 
0026 namespace tbb {
0027 /** \name combinable
0028     **/
0029 //@{
0030 //! Thread-local storage with optional reduction
0031 /** @ingroup containers */
0032     template <typename T>
0033     class combinable {
0034 
0035     private:
0036         typedef typename tbb::cache_aligned_allocator<T> my_alloc;
0037         typedef typename tbb::enumerable_thread_specific<T, my_alloc, ets_no_key> my_ets_type;
0038         my_ets_type my_ets;
0039 
0040     public:
0041 
0042         combinable() { }
0043 
0044         template <typename finit>
0045         explicit combinable( finit _finit) : my_ets(_finit) { }
0046 
0047         //! destructor
0048         ~combinable() { }
0049 
0050         combinable( const combinable& other) : my_ets(other.my_ets) { }
0051 
0052 #if __TBB_ETS_USE_CPP11
0053         combinable( combinable&& other) : my_ets( std::move(other.my_ets)) { }
0054 #endif
0055 
0056         combinable & operator=( const combinable & other) {
0057             my_ets = other.my_ets;
0058             return *this;
0059         }
0060 
0061 #if __TBB_ETS_USE_CPP11
0062         combinable & operator=( combinable && other) {
0063             my_ets=std::move(other.my_ets);
0064             return *this;
0065         }
0066 #endif
0067 
0068         void clear() { my_ets.clear(); }
0069 
0070         T& local() { return my_ets.local(); }
0071 
0072         T& local(bool & exists) { return my_ets.local(exists); }
0073 
0074         // combine_func_t has signature T(T,T) or T(const T&, const T&)
0075         template <typename combine_func_t>
0076         T combine(combine_func_t f_combine) { return my_ets.combine(f_combine); }
0077 
0078         // combine_func_t has signature void(T) or void(const T&)
0079         template <typename combine_func_t>
0080         void combine_each(combine_func_t f_combine) { my_ets.combine_each(f_combine); }
0081 
0082     };
0083 } // namespace tbb
0084 
0085 #include "internal/_warning_suppress_disable_notice.h"
0086 #undef __TBB_combinable_H_include_area
0087 
0088 #endif /* __TBB_combinable_H */