rcpp_progress icon indicating copy to clipboard operation
rcpp_progress copied to clipboard

Multithreading agnostic progress bar (RcppParallel, pthreads, openmp)

Open traversc opened this issue 4 years ago • 2 comments

I wrote a short gist based on the idea in this package that should work for RcppParallel and any other multithreading framework. https://gist.github.com/traversc/8b26b9e689b23d3a174aee296c0503ca

I think this general approach would be nice to see in this package.

The changes you'd need to make are not too many. In summary:

  • counter -> std::atomic
  • increment -> counter.fetch_add(1)
  • Check for main thread -> std::this_thread::get_id()

traversc avatar Sep 16 '21 02:09 traversc

Hello, What are the practical advantages ?

kforner avatar Sep 16 '21 06:09 kforner

The practical advantage is it should work using RcppParallel or C++ std::threads.

traversc avatar Sep 16 '21 16:09 traversc