35 #include "vtkCommonCoreModule.h" 38 #include "vtkSMPThreadLocal.h" 39 #include "vtkSMPToolsInternal.h" 42 #ifndef DOXYGEN_SHOULD_SKIP_THIS 51 class vtkSMPTools_Has_Initialize
53 typedef char (&no_type)[1];
54 typedef char (&yes_type)[2];
55 template <
typename U,
void (U::*)()>
struct V {};
56 template <
typename U>
static yes_type check(V<U, &U::Initialize>*);
57 template <
typename U>
static no_type check(...);
59 static bool const value =
sizeof(check<T>(
nullptr)) ==
sizeof(yes_type);
63 class vtkSMPTools_Has_Initialize_const
65 typedef char (&no_type)[1];
66 typedef char (&yes_type)[2];
67 template <
typename U,
void (U::*)() const>
struct V {};
68 template <
typename U>
static yes_type check(V<U, &U::Initialize>*);
69 template <
typename U>
static no_type check(...);
71 static bool const value =
sizeof(check<T>(0)) ==
sizeof(yes_type);
74 template <
typename Functor,
bool Init>
75 struct vtkSMPTools_FunctorInternal;
77 template <
typename Functor>
78 struct vtkSMPTools_FunctorInternal<Functor, false>
81 vtkSMPTools_FunctorInternal(Functor& f): F(f) {}
88 vtk::detail::smp::vtkSMPTools_Impl_For(first, last, grain, *
this);
90 vtkSMPTools_FunctorInternal<Functor, false>& operator=(
91 const vtkSMPTools_FunctorInternal<Functor, false>&);
92 vtkSMPTools_FunctorInternal<Functor, false>(
93 const vtkSMPTools_FunctorInternal<Functor, false>&);
96 template <
typename Functor>
97 struct vtkSMPTools_FunctorInternal<Functor, true>
100 vtkSMPThreadLocal<unsigned char> Initialized;
101 vtkSMPTools_FunctorInternal(Functor& f): F(f), Initialized(0) {}
104 unsigned char& inited = this->Initialized.Local();
107 this->F.Initialize();
110 this->F(first, last);
114 vtk::detail::smp::vtkSMPTools_Impl_For(first, last, grain, *
this);
117 vtkSMPTools_FunctorInternal<Functor, true>& operator=(
118 const vtkSMPTools_FunctorInternal<Functor, true>&);
119 vtkSMPTools_FunctorInternal<Functor, true>(
120 const vtkSMPTools_FunctorInternal<Functor, true>&);
123 template <
typename Functor>
124 class vtkSMPTools_Lookup_For
128 typedef vtkSMPTools_FunctorInternal<Functor, init>
type;
131 template <
typename Functor>
132 class vtkSMPTools_Lookup_For<Functor const>
136 typedef vtkSMPTools_FunctorInternal<Functor const, init>
type;
141 #endif // __VTK_WRAP__ 142 #endif // DOXYGEN_SHOULD_SKIP_THIS 158 template <
typename Functor>
162 fi.For(first, last, grain);
176 template <
typename Functor>
180 fi.For(first, last, grain);
193 template <
typename Functor>
208 template <
typename Functor>
224 static void Initialize(
int numThreads=0);
232 static int GetEstimatedNumberOfThreads();
239 template<
typename RandomAccessIterator>
240 static void Sort(RandomAccessIterator begin, RandomAccessIterator end)
242 vtk::detail::smp::vtkSMPTools_Impl_Sort(begin,end);
251 template<
typename RandomAccessIterator,
typename Compare>
252 static void Sort(RandomAccessIterator begin, RandomAccessIterator end,
255 vtk::detail::smp::vtkSMPTools_Impl_Sort(begin,end,comp);