From dfa2c7a95050320540e002c28be26ee75f4cb57d Mon Sep 17 00:00:00 2001 From: gabime Date: Mon, 22 Aug 2016 21:48:57 +0300 Subject: [PATCH] async flush now waits for queue to be empty before returning --- include/spdlog/details/async_log_helper.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index 4a426389..c4c39552 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -246,8 +246,14 @@ inline void spdlog::details::async_log_helper::push_msg(details::async_log_helpe } +//wait for the queue be empty and request flush from its sinks inline void spdlog::details::async_log_helper::flush() { + auto last_op = details::os::now(); + while (_q.approx_size() > 0) + { + sleep_or_yield(details::os::now(), last_op); + } push_msg(async_msg(async_msg_type::flush)); }