mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Logging: Fixed log message order not being preserved when async logging was enabled and ThreadPool was greater than 1
Despite that issue, logging was still threadsafe, just not ordered properly
This commit is contained in:
@@ -35,7 +35,11 @@ namespace Trinity
|
||||
Strand(IoContext& ioContext) : boost::asio::io_context::strand(ioContext) { }
|
||||
};
|
||||
|
||||
using boost::asio::bind_executor;
|
||||
template<typename T>
|
||||
inline decltype(auto) post(boost::asio::io_context::strand& strand, T&& t)
|
||||
{
|
||||
return boost::asio::post(strand, std::forward<T>(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ void Log::write(std::unique_ptr<LogMessage> msg) const
|
||||
if (_ioContext)
|
||||
{
|
||||
std::shared_ptr<LogOperation> logOperation = std::make_shared<LogOperation>(logger, std::move(msg));
|
||||
Trinity::Asio::post(*_ioContext, Trinity::Asio::bind_executor(*_strand, [logOperation]() { logOperation->call(); }));
|
||||
Trinity::Asio::post(*_strand, [logOperation]() { logOperation->call(); });
|
||||
}
|
||||
else
|
||||
logger->write(msg.get());
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#include "Metric.h"
|
||||
#include "Config.h"
|
||||
#include "DeadlineTimer.h"
|
||||
#include "IoContext.h"
|
||||
#include "Log.h"
|
||||
#include "Strand.h"
|
||||
#include "Util.h"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
Reference in New Issue
Block a user