diff options
author | Machiavelli <none@none> | 2010-09-27 00:20:56 +0200 |
---|---|---|
committer | Machiavelli <none@none> | 2010-09-27 00:20:56 +0200 |
commit | a9e9a2c8848c22e4a3e3b7bab0caeca25d9ea408 (patch) | |
tree | a7c4960796d0a9a42cb1e0252d4a75c4436d1f01 /src/server/shared/Database/MySQLConnection.h | |
parent | 894b2081b3837575bd44c71ea4ebc76008b5b5e3 (diff) |
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
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
Diffstat (limited to 'src/server/shared/Database/MySQLConnection.h')
-rw-r--r-- | src/server/shared/Database/MySQLConnection.h | 16 |
1 files changed, 16 insertions, 0 deletions
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 <class T> 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<MySQLPreparedStatement*> 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. |