aboutsummaryrefslogtreecommitdiff
path: root/src/server/database/Database/MySQLConnection.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-12-14 17:00:58 +0100
committerfunjoker <funjoker109@gmail.com>2023-12-19 14:09:02 +0100
commit31d79bae9c6dc80818c69505999484b310fe82c3 (patch)
tree7ffee1fb39188f6242e96961fa5990d7935f44da /src/server/database/Database/MySQLConnection.cpp
parent1d7d2e99f12de089e82b4eed3c4ae4ed25229dd4 (diff)
Core/Database: Refactor MySQLConnection constructors and async thread creation
(cherry picked from commit 5c59e2a248c9b2132f4e863de56c981cfa83ec0b)
Diffstat (limited to 'src/server/database/Database/MySQLConnection.cpp')
-rw-r--r--src/server/database/Database/MySQLConnection.cpp19
1 files changed, 7 insertions, 12 deletions
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<SQLOperation*>* 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<DatabaseWorker>(m_queue, this);
}
MySQLConnection::~MySQLConnection()
@@ -452,6 +442,11 @@ uint32 MySQLConnection::GetLastError()
return mysql_errno(m_Mysql);
}
+void MySQLConnection::StartDatabaseWorkerThread(ProducerConsumerQueue<SQLOperation*>* queue)
+{
+ m_worker = std::make_unique<DatabaseWorker>(queue, this);
+}
+
bool MySQLConnection::LockIfReady()
{
return m_Mutex.try_lock();