Cockatrice/servatrice/src/servatrice_connection_pool.h
BruebachL ec3ad812f0
[Server] Accept the database interface in the connection pool (#7853)
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.
2026-11-10 12:16:31 +01:00

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