mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
Servatrice_ConnectionPool stored and returned a concrete Servatrice_DatabaseInterface pointer, so the pool that decides which database a socket handler runs against could not hold any other Server_DatabaseInterface. Retype the constructor, member and accessor, and include the interface header instead of the Servatrice one. The shipped path still builds MySQL pools and converts implicitly; behaviour is unchanged.
47 lines
995 B
C++
47 lines
995 B
C++
#ifndef SERVATRICE_CONNECTION_POOL_H
|
|
#define SERVATRICE_CONNECTION_POOL_H
|
|
|
|
#include <QMutex>
|
|
#include <QMutexLocker>
|
|
#include <QObject>
|
|
#include <qtmetamacros.h>
|
|
|
|
class Server_DatabaseInterface;
|
|
|
|
class Servatrice_ConnectionPool : public QObject
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
Server_DatabaseInterface *databaseInterface;
|
|
bool threaded;
|
|
mutable QMutex clientCountMutex;
|
|
int clientCount;
|
|
|
|
public:
|
|
explicit Servatrice_ConnectionPool(Server_DatabaseInterface *_databaseInterface);
|
|
~Servatrice_ConnectionPool() override;
|
|
|
|
Server_DatabaseInterface *getDatabaseInterface() const
|
|
{
|
|
return databaseInterface;
|
|
}
|
|
|
|
int getClientCount() const
|
|
{
|
|
QMutexLocker locker(&clientCountMutex);
|
|
return clientCount;
|
|
}
|
|
void addClient()
|
|
{
|
|
QMutexLocker locker(&clientCountMutex);
|
|
++clientCount;
|
|
}
|
|
public slots:
|
|
void removeClient()
|
|
{
|
|
QMutexLocker locker(&clientCountMutex);
|
|
--clientCount;
|
|
}
|
|
};
|
|
|
|
#endif
|