mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
added tp getter to async api
This commit is contained in:
parent
c568640595
commit
ef5c4f027c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user