This commit is contained in:
Torsten (PC)
2026-01-14 14:36:57 +01:00
parent cd739fb52e
commit 1fe77c0905
21 changed files with 1267 additions and 0 deletions

24
src/connection_guard.h Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
#include "connection_pool.h"
#include <memory>
class ConnectionGuard {
public:
ConnectionGuard(ConnectionPool &pool)
: pool(pool), connection(pool.getConnection()) {}
~ConnectionGuard() {
if (connection) {
pool.releaseConnection(connection);
}
}
Database &get() {
return *connection;
}
private:
ConnectionPool &pool;
std::shared_ptr<Database> connection;
};