فهرست منبع

Logging: Don't lock the queue for the duration of the write

James Rowe 8 سال پیش
والد
کامیت
6daebaaa57
1فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 5 3
      src/common/logging/backend.cpp

+ 5 - 3
src/common/logging/backend.cpp

@@ -83,8 +83,10 @@ private:
                 }
                 }
             };
             };
             while (true) {
             while (true) {
-                std::unique_lock<std::mutex> lock(message_mutex);
-                message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
+                {
+                    std::unique_lock<std::mutex> lock(message_mutex);
+                    message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
+                }
                 if (!running) {
                 if (!running) {
                     break;
                     break;
                 }
                 }
@@ -282,4 +284,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
 
 
     Impl::Instance().PushEntry(std::move(entry));
     Impl::Instance().PushEntry(std::move(entry));
 }
 }
-} // namespace Log
+} // namespace Log