oss_src/parallel/lambda_omp.hpp
inline void in_parallel(const std::function<void (size_t thread_id, 
                                                  size_t num_threads)>& fn) {
  size_t nworkers = thread_pool::get_instance().size();

  if (thread::get_tls_data().is_in_thread() || nworkers <= 1) {

    fn(0, 1);
    return;

  } else {

    parallel_task_queue threads(thread_pool::get_instance());

    for (size_t i = 0;i < nworkers; ++i) {
      threads.launch([&fn, i, nworkers]() { fn(i, nworkers); }, i);
    }
    threads.join();
  }
}
/**
 * Runs a provided function in parallel, passing the function the thread ID 
 * and the number of threads. The thread ID is always between 0 and 
 * #threads - 1. 
 *
 * \code
 *  in_parallel([&](size_t thrid, size_t num_threads) {
 *                   std::cout << "Thread " << thrid << " out of " 
 *                             << num_threads << "\n";
 *                 });
 * \endcode
 *
 * \param fn The function to run. The function must take two size_t arguments:
 *           the thread ID and the number of threads.
 */
Runs a provided function in parallel, passing the function the thread ID
and the number of threads. The thread ID is always between 0 and
#threads - 1.



\param fn The function to run. The function must take two size_t arguments:
the thread ID and the number of threads.
Runs a provided function in parallel passing the function the thread ID and the number of threads . The thread ID is always between 0 and #threads - 1 . \ param fn The function to run . The function must take two size_t arguments : the thread ID and the number of threads .
inline void in_parallel(const std::function<void (size_t thread_id, 
                                                  size_t num_threads)>& fn) {
  size_t nworkers = thread_pool::get_instance().size();
  if (thread::get_tls_data().is_in_thread() || nworkers <= 1) {
    fn(0, 1);
    return;
  } else {
    parallel_task_queue threads(thread_pool::get_instance());
    for (size_t i = 0;i < nworkers; ++i) {
      threads.launch([&fn, i, nworkers]() { fn(i, nworkers); }, i);
    }
    threads.join();
  }
}
inline void in_parallel ( const std :: function < void ( size_t thread_id , size_t num_threads ) > & fn ) { size_t nworkers = thread_pool :: get_instance ( ) . size ( ) ; if ( thread :: get_tls_data ( ) . is_in_thread ( ) || nworkers <= 1 ) { fn ( 0 , 1 ) ; return ; } else { parallel_task_queue threads ( thread_pool :: get_instance ( ) ) ; for ( size_t i = 0 ; i < nworkers ; ++ i ) { threads . launch ( [ & fn , i , nworkers ] ( ) { fn ( i , nworkers ) ; } , i ) ; } threads . join ( ) ; } }
Runs a provided function in parallel, passing the function the thread ID
 and the number of threads.
Runs a provided function in parallel passing the function the thread ID and the number of threads .