|
|
@ -107,8 +107,9 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
void log(const details::log_msg& msg);
|
|
|
|
void log(const details::log_msg& msg);
|
|
|
|
|
|
|
|
|
|
|
|
//Stop logging and join the back thread
|
|
|
|
// stop logging and join the back thread
|
|
|
|
~async_log_helper();
|
|
|
|
~async_log_helper();
|
|
|
|
|
|
|
|
|
|
|
|
void set_formatter(formatter_ptr);
|
|
|
|
void set_formatter(formatter_ptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -141,7 +142,7 @@ private:
|
|
|
|
// return true if a message was available (queue was not empty), will set the last_pop to the pop time
|
|
|
|
// return true if a message was available (queue was not empty), will set the last_pop to the pop time
|
|
|
|
bool process_next_msg(clock::time_point& last_pop);
|
|
|
|
bool process_next_msg(clock::time_point& last_pop);
|
|
|
|
|
|
|
|
|
|
|
|
// guess how much to sleep if queue is empty/full using last successful op time as hint
|
|
|
|
// sleep,yield or return immediatly using the time passed since last message as a hint
|
|
|
|
static void sleep_or_yield(const clock::time_point& last_op_time);
|
|
|
|
static void sleep_or_yield(const clock::time_point& last_op_time);
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -210,8 +211,8 @@ inline void spdlog::details::async_log_helper::worker_loop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Process next message in the queue
|
|
|
|
// process next message in the queue
|
|
|
|
// Return true if this thread should still be active (no msg with level::off was received)
|
|
|
|
// return true if this thread should still be active (no msg with level::off was received)
|
|
|
|
inline bool spdlog::details::async_log_helper::process_next_msg(clock::time_point& last_pop)
|
|
|
|
inline bool spdlog::details::async_log_helper::process_next_msg(clock::time_point& last_pop)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
@ -243,7 +244,7 @@ inline void spdlog::details::async_log_helper::set_formatter(formatter_ptr msg_f
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sleep,yield or return immediatly using the time passed since last message as a hint
|
|
|
|
// sleep,yield or return immediatly using the time passed since last message as a hint
|
|
|
|
inline void spdlog::details::async_log_helper::sleep_or_yield(const clock::time_point& last_op_time)
|
|
|
|
inline void spdlog::details::async_log_helper::sleep_or_yield(const clock::time_point& last_op_time)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using std::chrono::milliseconds;
|
|
|
|
using std::chrono::milliseconds;
|
|
|
|