|
|
|
@ -10,21 +10,21 @@
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace spdlog {
|
|
|
|
|
namespace details {
|
|
|
|
|
namespace details {
|
|
|
|
|
|
|
|
|
|
using async_logger_ptr = std::shared_ptr<spdlog::async_logger>;
|
|
|
|
|
using async_logger_ptr = std::shared_ptr<spdlog::async_logger>;
|
|
|
|
|
|
|
|
|
|
enum class async_msg_type
|
|
|
|
|
{
|
|
|
|
|
enum class async_msg_type
|
|
|
|
|
{
|
|
|
|
|
log,
|
|
|
|
|
flush,
|
|
|
|
|
terminate
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Async msg to move to/from the queue
|
|
|
|
|
// Movable only. should never be copied
|
|
|
|
|
struct async_msg
|
|
|
|
|
{
|
|
|
|
|
// Async msg to move to/from the queue
|
|
|
|
|
// Movable only. should never be copied
|
|
|
|
|
struct async_msg
|
|
|
|
|
{
|
|
|
|
|
async_msg_type msg_type;
|
|
|
|
|
level::level_enum level;
|
|
|
|
|
log_clock::time_point time;
|
|
|
|
@ -78,11 +78,11 @@ namespace spdlog {
|
|
|
|
|
msg.color_range_start = 0;
|
|
|
|
|
msg.color_range_end = 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class thread_pool
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
class thread_pool
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
using item_type = async_msg;
|
|
|
|
|
using q_type = details::mpmc_blocking_queue<item_type>;
|
|
|
|
|
using clock_type = std::chrono::steady_clock;
|
|
|
|
@ -139,7 +139,7 @@ namespace spdlog {
|
|
|
|
|
return msg_counter_.load(std::memory_order_relaxed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
private:
|
|
|
|
|
std::atomic<size_t> msg_counter_; // total # of messages processed in this pool
|
|
|
|
|
q_type _q;
|
|
|
|
|
|
|
|
|
@ -159,9 +159,7 @@ namespace spdlog {
|
|
|
|
|
|
|
|
|
|
void worker_loop()
|
|
|
|
|
{
|
|
|
|
|
while (process_next_msg())
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
while (process_next_msg()) {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// process next message in the queue
|
|
|
|
@ -200,7 +198,7 @@ namespace spdlog {
|
|
|
|
|
assert(false);
|
|
|
|
|
return true; // should not be reached
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace details
|
|
|
|
|
} // namespace details
|
|
|
|
|
} // namespace spdlog
|
|
|
|
|