Update of code

main
anulax1225 ago%!(EXTRA string=2 months)
parent 26fae7f1e6
commit 0efae716cd
  1. 2
      src/bakatools/logging/log.cpp
  2. 3
      src/bakatools/thread/task_pool.h

@ -9,7 +9,7 @@ namespace Bk {
{ {
std::vector<spdlog::sink_ptr> log_sinks; std::vector<spdlog::sink_ptr> log_sinks;
log_sinks.emplace_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>()); log_sinks.emplace_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
log_sinks[0]->set_pattern("%^[%T] %n: %v%$"); log_sinks[0]->set_pattern("%^[%T] %n(thread %t) %v%$");
if (file_log) if (file_log)
{ {
log_sinks.emplace_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>("bakara.log", true)); log_sinks.emplace_back(std::make_shared<spdlog::sinks::basic_file_sink_mt>("bakara.log", true));

@ -19,6 +19,7 @@ namespace Bk
threads_.emplace_back([this] { threads_.emplace_back([this] {
while (true) { while (true) {
std::function<void()> task; std::function<void()> task;
{ {
std::unique_lock<std::mutex> lock(queue_mutex_); std::unique_lock<std::mutex> lock(queue_mutex_);
cv_.wait(lock, [this] { cv_.wait(lock, [this] {
@ -32,6 +33,7 @@ namespace Bk
task = std::move(tasks_.front()); task = std::move(tasks_.front());
tasks_.pop(); tasks_.pop();
} }
task(); task();
} }
}); });
@ -65,6 +67,7 @@ namespace Bk
{ {
std::unique_lock<std::mutex> lock(queue_mutex_); std::unique_lock<std::mutex> lock(queue_mutex_);
stop_ = true; stop_ = true;
cv_.notify_one();
} }
private: private:

Loading…
Cancel
Save