Commit ef5c4f02 authored by gabime's avatar gabime

added tp getter to async api

parent c5686405
......@@ -69,11 +69,10 @@ int main(int argc, char *argv[])
auto as = spdlog::create_async_logger<null_sink_mt>("async(null-sink)");
total_rate += bench_as(howmany, as, client_threads);
spdlog::drop("async(null-sink)");
spdlog::details::registry::instance().get_thread_pool()->wait_empty ();
spdlog::thread_pool()->wait_empty();
}
std::cout << endl;
std::cout << "Avg rate: " << format(total_rate / iters) << "/sec" << std::endl;
}
catch (std::exception &ex)
{
......
......@@ -74,12 +74,13 @@ int main(int argc, char *argv[])
cout << "async logging.. " << threads << " threads sharing same logger, " << format(howmany) << " iterations " << endl;
cout << "*******************************************************************************\n";
spdlog::init_thread_pool(queue_size, 1);
for (int i = 0; i < 3; ++i)
{
spdlog::init_thread_pool(queue_size, 1);
auto as = spdlog::basic_logger_mt<spdlog::create_async>("as", "logs/basic_async.log", true);
bench_mt(howmany, as, threads);
spdlog::drop("as");
spdlog::thread_pool()->wait_empty();
}
}
catch (std::exception &ex)
......
......@@ -59,4 +59,10 @@ inline void init_thread_pool(size_t q_size, size_t thread_count)
auto tp = std::make_shared<thread_pool>(q_size, thread_count);
registry::instance().set_thread_pool(std::move(tp));
}
// get the global thread pool.
inline std::shared_ptr<spdlog::details::thread_pool> thread_pool()
{
return details::registry::instance().get_thread_pool();
}
} // namespace spdlog
......@@ -108,7 +108,6 @@ TEST_CASE("multi threads", "[async]")
{
t.join();
}
}
REQUIRE(test_sink->msg_counter() == messages * n_threads);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment