00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __TBB_combinable_H
00022 #define __TBB_combinable_H
00023
00024 #include "tbb/enumerable_thread_specific.h"
00025 #include "tbb/cache_aligned_allocator.h"
00026
00027 namespace tbb {
00031
00032
00033 template <typename T>
00034 class combinable {
00035 private:
00036 typedef typename tbb::cache_aligned_allocator<T> my_alloc;
00037
00038 typedef typename tbb::enumerable_thread_specific<T, my_alloc, ets_no_key> my_ets_type;
00039 my_ets_type my_ets;
00040
00041 public:
00042
00043 combinable() { }
00044
00045 template <typename finit>
00046 combinable( finit _finit) : my_ets(_finit) { }
00047
00049 ~combinable() {
00050 }
00051
00052 combinable(const combinable& other) : my_ets(other.my_ets) { }
00053
00054 combinable & operator=( const combinable & other) { my_ets = other.my_ets; return *this; }
00055
00056 void clear() { my_ets.clear(); }
00057
00058 T& local() { return my_ets.local(); }
00059
00060 T& local(bool & exists) { return my_ets.local(exists); }
00061
00062 template< typename FCombine>
00063 T combine(FCombine fcombine) { return my_ets.combine(fcombine); }
00064
00065 template<typename FCombine>
00066 void combine_each(FCombine fcombine) { my_ets.combine_each(fcombine); }
00067
00068 };
00069 }
00070 #endif