mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-29 10:03:55 -07:00
initial commit for connection pools
This commit is contained in:
parent
c2edd33e90
commit
981db47f9e
21 changed files with 829 additions and 700 deletions
29
servatrice/src/servatrice_connection_pool.h
Normal file
29
servatrice/src/servatrice_connection_pool.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef SERVATRICE_CONNECTION_POOL_H
|
||||
#define SERVATRICE_CONNECTION_POOL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
|
||||
class Servatrice_DatabaseInterface;
|
||||
|
||||
class Servatrice_ConnectionPool : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
Servatrice_DatabaseInterface *databaseInterface;
|
||||
mutable QMutex clientCountMutex;
|
||||
int clientCount;
|
||||
public:
|
||||
Servatrice_ConnectionPool(Servatrice_DatabaseInterface *_databaseInterface)
|
||||
: databaseInterface(_databaseInterface), clientCount(0)
|
||||
{
|
||||
}
|
||||
Servatrice_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
|
||||
Loading…
Add table
Add a link
Reference in a new issue