// Copyright (c) 2019 The Zano developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #pragma once #include #include "include_base_utils.h" #include "common/threads_pool.h" inline void thread_pool_tests() { { utils::threads_pool pool; pool.init(); std::atomic count_jobs_finished = 0; size_t i = 0; for (; i != 10; i++) { pool.add_job([&, i]() {LOG_PRINT_L0("Job " << i << " started"); epee::misc_utils::sleep_no_w(10000); ++count_jobs_finished; LOG_PRINT_L0("Job " << i << " finished"); }); } while (count_jobs_finished != i) { epee::misc_utils::sleep_no_w(500); } LOG_PRINT_L0("All jobs finished"); } LOG_PRINT_L0("Scope left"); }