TimerWorker::~TimerWorker() { // stop the worker if (started && !stop) { stop_and_join(); } pthread_mutex_destroy(&mutex); pthread_cond_destroy(&cond); }
executor::executor(size_t n) { threads_.reserve(n); try { for (size_t i = 0; i < n; ++i) threads_.emplace_back([&]() { try { while (true) queue_.pop()(); } catch (std::runtime_error const &e) { return; } }); } catch (std::exception const &e) { stop_and_join(); } }
executor::~executor() { stop_and_join(); }