27 std::cerr <<
"[threadPool] Warning: clear() called (probably from a "
29 <<
tasks_.size() <<
" pending tasks. Aborting them.\n";
32 if (t.joinable()) t.join();
43 for (std::size_t i = 0; i < num_threads; ++i)
49 std::function<void()> task;
51 std::unique_lock<std::mutex> lock(queue_mutex_);
52 condition_.wait(lock, [this] {
53 return do_stop_ || !tasks_.empty();
56 task = std::move(tasks_.front());
62 catch (std::exception& e)
64 std::cerr <<
"[thread-pool] Exception:\n"
65 << mrpt::exception_to_str(e) <<
"\n";