From 5c59e2a248c9b2132f4e863de56c981cfa83ec0b Mon Sep 17 00:00:00 2001 From: Shauren Date: Thu, 14 Dec 2023 17:00:58 +0100 Subject: Core/Database: Refactor MySQLConnection constructors and async thread creation --- src/server/database/Database/MySQLConnection.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/server/database/Database/MySQLConnection.cpp') diff --git a/src/server/database/Database/MySQLConnection.cpp b/src/server/database/Database/MySQLConnection.cpp index 3383f9507ed..c42ca4e2903 100644 --- a/src/server/database/Database/MySQLConnection.cpp +++ b/src/server/database/Database/MySQLConnection.cpp @@ -47,23 +47,13 @@ MySQLConnectionInfo::MySQLConnectionInfo(std::string const& infoString) ssl.assign(tokens[5]); } -MySQLConnection::MySQLConnection(MySQLConnectionInfo& connInfo) : +MySQLConnection::MySQLConnection(MySQLConnectionInfo& connInfo, ConnectionFlags connectionFlags) : m_reconnecting(false), m_prepareError(false), -m_queue(nullptr), m_Mysql(nullptr), m_connectionInfo(connInfo), -m_connectionFlags(CONNECTION_SYNCH) { } - -MySQLConnection::MySQLConnection(ProducerConsumerQueue* queue, MySQLConnectionInfo& connInfo) : -m_reconnecting(false), -m_prepareError(false), -m_queue(queue), -m_Mysql(nullptr), -m_connectionInfo(connInfo), -m_connectionFlags(CONNECTION_ASYNC) +m_connectionFlags(connectionFlags) { - m_worker = std::make_unique(m_queue, this); } MySQLConnection::~MySQLConnection() @@ -452,6 +442,11 @@ uint32 MySQLConnection::GetLastError() return mysql_errno(m_Mysql); } +void MySQLConnection::StartDatabaseWorkerThread(ProducerConsumerQueue* queue) +{ + m_worker = std::make_unique(queue, this); +} + bool MySQLConnection::LockIfReady() { return m_Mutex.try_lock(); -- cgit v1.2.3