mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 01:29:35 +08:00
balagan
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
namespace c11log {
|
||||
namespace details
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
class blocking_queue {
|
||||
public:
|
||||
@@ -58,7 +59,7 @@ public:
|
||||
// If the queue is full, block the calling thread until there is room.
|
||||
void push(const T& item)
|
||||
{
|
||||
while (!push(item, std::chrono::hours::max()));
|
||||
while (!push(item, one_hour));
|
||||
}
|
||||
|
||||
// Pop a copy of the front item in the queue into the given item ref.
|
||||
@@ -87,7 +88,7 @@ public:
|
||||
// If the queue is empty, block the calling thread util there is item to pop.
|
||||
void pop(T& item)
|
||||
{
|
||||
while (!pop(item, std::chrono::hours::max()));
|
||||
while (!pop(item, one_hour));
|
||||
}
|
||||
|
||||
// Clear the queue
|
||||
@@ -102,7 +103,10 @@ private:
|
||||
std::queue<T> q_;
|
||||
std::mutex mutex_;
|
||||
std::condition_variable item_pushed_cond_;
|
||||
std::condition_variable item_popped_cond_;
|
||||
std::condition_variable item_popped_cond_;
|
||||
static constexpr auto one_hour = std::chrono::seconds(3);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,8 +10,8 @@ namespace c11log
|
||||
namespace os
|
||||
{
|
||||
std::tm localtime(const std::time_t &time_t);
|
||||
std::tm localtime();
|
||||
std::tm localtime();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -60,8 +60,9 @@ inline void c11log::sinks::async_sink::sink_it_(const std::string& msg)
|
||||
|
||||
inline void c11log::sinks::async_sink::thread_loop_()
|
||||
{
|
||||
constexpr auto pop_timeout = std::chrono::seconds(1);
|
||||
std::string msg;
|
||||
auto pop_timeout = std::chrono::seconds(1);
|
||||
|
||||
while (active_)
|
||||
{
|
||||
if (q_.pop(msg, pop_timeout))
|
||||
|
Reference in New Issue
Block a user