// TJP COPYRIGHT HEADER #include "Parallel.hpp" #include namespace tjp::core::threads { Parallel::Parallel(int max, int free) { start(max, free); } Parallel::~Parallel() { stop(); } void Parallel::start(int max, int free) { auto lock = lock_of(mutex); if (running) return; running = true; auto n_ = std::max( 1, std::min( max, (int)std::thread::hardware_concurrency() - free ) ); n = n_; debug_assert(n > 0 && n <= max); threads = new std::thread[n]; for (auto m=0; m::max(); event.notify_all(); auto n = std::thread::hardware_concurrency(); for (auto m=0; m