5#include "../SqlConnection.hpp"
7#include "SqlBackup.hpp"
9#include <condition_variable>
14namespace Lightweight::SqlBackup::detail
30 LIGHTWEIGHT_API Lease(Lease&& other)
noexcept;
31 Lease& operator=(Lease&&) =
delete;
32 Lease(Lease
const&) =
delete;
33 Lease& operator=(Lease
const&) =
delete;
34 LIGHTWEIGHT_API ~Lease();
37 [[nodiscard]] SqlConnection& Get() const noexcept
43 friend class ConnectionPool;
44 Lease(ConnectionPool& pool, std::unique_ptr<SqlConnection> conn)
noexcept;
45 ConnectionPool* _pool;
46 std::unique_ptr<SqlConnection> _conn;
55 LIGHTWEIGHT_API ConnectionPool(SqlConnectionString
const& connectionString,
57 RetrySettings
const& retrySettings,
58 ProgressManager& progress);
60 ConnectionPool(ConnectionPool
const&) =
delete;
61 ConnectionPool& operator=(ConnectionPool
const&) =
delete;
62 ConnectionPool(ConnectionPool&&) =
delete;
63 ConnectionPool& operator=(ConnectionPool&&) =
delete;
64 ~ConnectionPool() =
default;
68 [[nodiscard]] LIGHTWEIGHT_API Lease Acquire();
71 void Return(std::unique_ptr<SqlConnection> conn)
noexcept;
74 std::condition_variable _cv;
75 std::vector<std::unique_ptr<SqlConnection>> _idle;