/*========================================================================= Program: Visualization Toolkit Module: vtkSMPToolsInternal.h.in Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkNew.h" #include #include #include namespace vtk { namespace detail { namespace smp { //-------------------------------------------------------------------------------- template class FuncCall { T& o; void operator=(const FuncCall&) = delete; public: void operator() (const tbb::blocked_range& r) const { o.Execute(r.begin(), r.end()); } FuncCall (T& _o) : o(_o) { } }; //-------------------------------------------------------------------------------- template void vtkSMPTools_Impl_For( vtkIdType first, vtkIdType last, vtkIdType grain, FunctorInternal& fi) { vtkIdType n = last - first; if (!n) { return; } if (grain > 0) { tbb::parallel_for(tbb::blocked_range(first, last, grain), FuncCall(fi)); } else { tbb::parallel_for(tbb::blocked_range(first, last), FuncCall(fi)); } } //-------------------------------------------------------------------------------- template void vtkSMPTools_Impl_Sort(RandomAccessIterator begin, RandomAccessIterator end) { tbb::parallel_sort(begin, end); } //-------------------------------------------------------------------------------- template void vtkSMPTools_Impl_Sort(RandomAccessIterator begin, RandomAccessIterator end, Compare comp) { tbb::parallel_sort(begin, end, comp); } }//namespace smp }//namespace detail }//namespace vtk