|
Lightweight 0.20260617.0
|
#include <Pool.hpp>
Classes | |
| class | PooledDataMapper |
Public Member Functions | |
| Pool () | |
| ~Pool () noexcept | |
| Pool (Pool const &)=delete | |
| Pool & | operator= (Pool const &)=delete |
| Pool (Pool &&)=delete | |
| Pool & | operator= (Pool &&)=delete |
| PooledDataMapper | Acquire () |
| PooledDataMapper | Acquire () |
| Async::Task< PooledDataMapper > | AcquireAsync (Async::IExecutor &dbWorkers, Async::IResumeScheduler &resume) |
| void | SetAsyncExecutors (Async::IExecutor &dbWorkers, Async::IResumeScheduler &resume) noexcept |
| Async::Task< PooledDataMapper > | AcquireAsync () |
A thread-safe pool of DataMapper instances with the policy configured by the PoolConfig template parameter. The pool allows acquiring and returning DataMapper instances, and manages the lifecycle of these instances according to the specified growth strategy.
|
inlineexplicit |
|
inlinenoexcept |
Destructor. The pool manages the lifecycle of the idle data mappers; be aware that any acquired data mappers not returned to the pool are destroyed when the pool is destroyed, which may leak resources if not handled properly.
Definition at line 216 of file Pool.hpp.
References Lightweight::SqlLogger::GetLogger(), and Lightweight::SqlLogger::OnWarning().
|
inline |
|
inline |
Function to acquire a data mapper from the pool, the behavior of this function depends on the growth strategy this is a specific implementation for the strategies that do not block, which always creates a new data mapper if the pool is empty, regardless of the maximum capacity
|
inline |
Asynchronously acquires a DataMapper from the pool without blocking the calling thread.
If the pool is exhausted (BoundedWait at capacity), the awaiting coroutine is suspended and resumed — via resume — when a mapper is returned, rather than parking a thread. The acquired mapper's connection is wired for async via SqlConnection::EnableAsync(dbWorkers, resume), so the caller can immediately co_await its async methods.
| dbWorkers | The worker pool used to run the acquired mapper's blocking ODBC calls. |
| resume | The scheduler used to resume coroutines (typically the app run loop). |
|
inlinenoexcept |
Configures the executors that the no-argument AcquireAsync() overload wires acquired mappers for, so async consumers of this pool no longer repeat the executors at every call.
This is opt-in and scoped to the pool: only pools configured this way hand out async-enabled mappers via the no-arg overload; synchronous Acquire and connections outside the pool are unaffected. Unlike a process-global default, the executors' lifetime is tied to this pool, which already must outlive every acquirer.
dbWorkers and resume must outlive this pool's async use (the same contract the explicit-argument AcquireAsync overload already implies). Only references are retained. Intended to be called once during setup, before any concurrent AcquireAsync(); it is not synchronized against in-flight acquirers. | dbWorkers | The worker pool used to run acquired mappers' blocking ODBC calls. |
| resume | The scheduler used to resume coroutines (typically the app run loop). |
|
inline |
Asynchronously acquires a DataMapper using the executors previously set via SetAsyncExecutors, without blocking the calling thread.
Equivalent to the explicit-argument AcquireAsync overload with the pool's stored executors; pass the executors to that overload to override them for a single call.
| std::logic_error | if SetAsyncExecutors has not been called on this pool. |