From a9e9a2c8848c22e4a3e3b7bab0caeca25d9ea408 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Mon, 27 Sep 2010 00:20:56 +0200 Subject: Core/DBLayer: - DB Threading model update * Get rid of ThreadBundleMask and bundled connection * Implement configurable amount of Synch threads for databasepools * Use modulus based algorithm to check for free synchronous connections instead of previous ¨get connection by thread key or bundlemask¨ feature * Locks on mysql context objects are now managed outside the mysql query methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue #4058 Fixes issue #4059 Introduces a ton of more issues. Use at own risk. You were warned. Really. Don´t forget to update your worldserver.conf --HG-- branch : trunk --- src/server/shared/Database/MySQLConnection.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/server/shared/Database/MySQLConnection.h') diff --git a/src/server/shared/Database/MySQLConnection.h b/src/server/shared/Database/MySQLConnection.h index 93812421c8a..f83d22218dd 100644 --- a/src/server/shared/Database/MySQLConnection.h +++ b/src/server/shared/Database/MySQLConnection.h @@ -25,10 +25,12 @@ class DatabaseWorker; class PreparedStatement; class MySQLPreparedStatement; +class PingOperation; class MySQLConnection { template friend class DatabaseWorkerPool; + friend class PingOperation; public: MySQLConnection(); //! Constructor for synchroneous connections. @@ -36,6 +38,7 @@ class MySQLConnection ~MySQLConnection(); virtual bool Open(const std::string& infoString); //! Connection details. + void Close(); public: bool Execute(const char* sql); @@ -58,6 +61,19 @@ class MySQLConnection void PrepareStatement(uint32 index, const char* sql); std::vector m_stmts; //! PreparedStatements storage + bool LockIfReady() + { + /// Tries to acquire lock. If lock is acquired by another thread + /// the calling parent will just try another connection + return m_Mutex.tryacquire() != -1; + } + + void Unlock() + { + /// Called by parent databasepool. Will let other threads access this connection + m_Mutex.release(); + } + private: ACE_Activation_Queue* m_queue; //! Queue shared with other asynchroneous connections. DatabaseWorker* m_worker; //! Core worker task. -- cgit v1.2.3