| 203 | |
| 204 | template <typename T> |
| 205 | void parallel_for ( |
| 206 | thread_pool& tp, |
| 207 | long begin, |
| 208 | long end, |
| 209 | T& obj, |
| 210 | void (T::*funct)(long), |
| 211 | long chunks_per_thread = 8 |
| 212 | ) |
| 213 | { |
| 214 | // make sure requires clause is not broken |
| 215 | DLIB_ASSERT(begin <= end && chunks_per_thread > 0, |
| 216 | "\t void parallel_for()" |
| 217 | << "\n\t Invalid inputs were given to this function" |
| 218 | << "\n\t begin: " << begin |
| 219 | << "\n\t end: " << end |
| 220 | << "\n\t chunks_per_thread: " << chunks_per_thread |
| 221 | ); |
| 222 | |
| 223 | impl::helper_parallel_for<T> helper(obj, funct); |
| 224 | parallel_for_blocked(tp, begin, end, helper, &impl::helper_parallel_for<T>::process_block, chunks_per_thread); |
| 225 | } |
| 226 | |
| 227 | // ---------------------------------------------------------------------------------------- |
| 228 | |