![]() |
fb-cpp 0.0.2
A modern C++ wrapper for the Firebird database API
|
Represents a thread-safe pool of Attachment objects connected to the same database. More...
#include <AttachmentPool.h>
Public Member Functions | |
| AttachmentPool (Client &client, std::string uri, const AttachmentPoolOptions &options={}) | |
| Constructs an AttachmentPool that connects to the database specified by the URI using the specified Client object and options. | |
| ~AttachmentPool () noexcept | |
| Closes every idle connection in the pool. | |
| AttachmentPool (const AttachmentPool &)=delete | |
| AttachmentPool & | operator= (const AttachmentPool &)=delete |
| AttachmentPool (AttachmentPool &&)=delete | |
| AttachmentPool & | operator= (AttachmentPool &&)=delete |
| Client & | getClient () noexcept |
| Returns the Client object reference used to create this AttachmentPool object. | |
| const std::string & | getUri () const noexcept |
| Returns the database URI this pool connects to. | |
| const AttachmentPoolOptions & | getOptions () const noexcept |
| Returns the options used to create this AttachmentPool object. | |
| std::size_t | size () |
| Returns the total number of connections currently created by the pool (in use plus available). | |
| std::size_t | availableCount () |
| Returns the number of connections currently available (not leased) in the pool. | |
| std::size_t | inUseCount () |
| Returns the number of connections currently leased out by the pool. | |
| PooledAttachment | acquire () |
| Acquires a connection from the pool, creating one if needed and allowed by getMaxSize(). | |
| std::optional< PooledAttachment > | tryAcquire () |
| Attempts to acquire a connection from the pool without throwing. | |
| void | close () |
| Closes every available connection and marks the pool as closed. | |
Friends | |
| class | PooledAttachment |
Represents a thread-safe pool of Attachment objects connected to the same database.
The pool itself is thread-safe, but each leased Attachment (and any Transaction or Statement created from it) must be used by a single thread at a time. The Client and the AttachmentPool must exist and remain valid while there are outstanding PooledAttachment leases.
Definition at line 337 of file AttachmentPool.h.
|
explicit |
Constructs an AttachmentPool that connects to the database specified by the URI using the specified Client object and options.
Definition at line 59 of file AttachmentPool.cpp.
|
noexcept |
Closes every idle connection in the pool.
All leases must be returned to the pool before it is destroyed.
Definition at line 87 of file AttachmentPool.cpp.
| PooledAttachment AttachmentPool::acquire | ( | ) |
Acquires a connection from the pool, creating one if needed and allowed by getMaxSize().
Blocks up to getAcquireTimeout() while the pool is exhausted, then throws FbCppException.
Definition at line 119 of file AttachmentPool.cpp.
| std::size_t AttachmentPool::availableCount | ( | ) |
Returns the number of connections currently available (not leased) in the pool.
Definition at line 107 of file AttachmentPool.cpp.
| void AttachmentPool::close | ( | ) |
Closes every available connection and marks the pool as closed.
Further calls to acquire() or tryAcquire() will fail.
Definition at line 131 of file AttachmentPool.cpp.
|
inlinenoexcept |
Returns the Client object reference used to create this AttachmentPool object.
Definition at line 364 of file AttachmentPool.h.
|
inlinenoexcept |
Returns the options used to create this AttachmentPool object.
Definition at line 380 of file AttachmentPool.h.
|
inlinenoexcept |
Returns the database URI this pool connects to.
Definition at line 372 of file AttachmentPool.h.
| std::size_t AttachmentPool::inUseCount | ( | ) |
Returns the number of connections currently leased out by the pool.
Definition at line 113 of file AttachmentPool.cpp.
| std::size_t AttachmentPool::size | ( | ) |
Returns the total number of connections currently created by the pool (in use plus available).
Definition at line 101 of file AttachmentPool.cpp.
| std::optional< PooledAttachment > AttachmentPool::tryAcquire | ( | ) |
Attempts to acquire a connection from the pool without throwing.
Returns std::nullopt if none becomes available within getAcquireTimeout().
Definition at line 126 of file AttachmentPool.cpp.
|
friend |
Definition at line 339 of file AttachmentPool.h.