|
|
|
@ -78,7 +78,7 @@ async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
|
|
|
|
|
txt = std::move(other.txt);
|
|
|
|
|
msg_type = other.msg_type;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// never copy or assign. should only be moved..
|
|
|
|
|
async_msg(const async_msg&) = delete;
|
|
|
|
@ -179,6 +179,9 @@ private:
|
|
|
|
|
// sleep,yield or return immediatly using the time passed since last message as a hint
|
|
|
|
|
static void sleep_or_yield(const spdlog::log_clock::time_point& now, const log_clock::time_point& last_op_time);
|
|
|
|
|
|
|
|
|
|
// wait until the queue is empty
|
|
|
|
|
void wait_empty_q();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -249,12 +252,9 @@ 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);
|
|
|
|
|
}
|
|
|
|
|
wait_empty_q();
|
|
|
|
|
push_msg(async_msg(async_msg_type::flush));
|
|
|
|
|
wait_empty_q(); //make sure the above flush message was processed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void spdlog::details::async_log_helper::worker_loop()
|
|
|
|
@ -366,6 +366,16 @@ inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_
|
|
|
|
|
return sleep_for(milliseconds(200));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wait for the queue to be empty
|
|
|
|
|
inline void spdlog::details::async_log_helper::wait_empty_q()
|
|
|
|
|
{
|
|
|
|
|
auto last_op = details::os::now();
|
|
|
|
|
while (_q.approx_size() > 0) {
|
|
|
|
|
sleep_or_yield(details::os::now(), last_op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|