Loading src/core/module/ThreadPool.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,14 @@ ThreadPool::ThreadPool(unsigned int num_threads, worker_init_function, worker_finalize_function); } // When running single-threadedly, execute initialize function directly and store finalize function for later if(threads_.empty()) { if(worker_init_function) { worker_init_function(); } finalize_function_ = worker_finalize_function; } } catch(...) { destroy(); throw; Loading Loading @@ -149,6 +157,11 @@ void ThreadPool::destroy() { thread.join(); } } // Execute the cleanup function at the end of run if running single-threaded if(threads_.empty() && finalize_function_) { finalize_function_(); } } bool ThreadPool::valid() { Loading src/core/module/ThreadPool.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ namespace allpix { using Task = std::unique_ptr<std::packaged_task<void()>>; SafeQueue<Task> queue_; bool with_buffered_{true}; std::function<void()> finalize_function_{}; std::atomic_bool done_{false}; Loading Loading
src/core/module/ThreadPool.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,14 @@ ThreadPool::ThreadPool(unsigned int num_threads, worker_init_function, worker_finalize_function); } // When running single-threadedly, execute initialize function directly and store finalize function for later if(threads_.empty()) { if(worker_init_function) { worker_init_function(); } finalize_function_ = worker_finalize_function; } } catch(...) { destroy(); throw; Loading Loading @@ -149,6 +157,11 @@ void ThreadPool::destroy() { thread.join(); } } // Execute the cleanup function at the end of run if running single-threaded if(threads_.empty() && finalize_function_) { finalize_function_(); } } bool ThreadPool::valid() { Loading
src/core/module/ThreadPool.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ namespace allpix { using Task = std::unique_ptr<std::packaged_task<void()>>; SafeQueue<Task> queue_; bool with_buffered_{true}; std::function<void()> finalize_function_{}; std::atomic_bool done_{false}; Loading