fb-cpp 0.0.2
A modern C++ wrapper for the Firebird database API
Loading...
Searching...
No Matches
fbcpp::AttachmentPool Class Referencefinal

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
 
AttachmentPooloperator= (const AttachmentPool &)=delete
 
 AttachmentPool (AttachmentPool &&)=delete
 
AttachmentPooloperator= (AttachmentPool &&)=delete
 
ClientgetClient () 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 AttachmentPoolOptionsgetOptions () 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< PooledAttachmenttryAcquire ()
 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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AttachmentPool()

AttachmentPool::AttachmentPool ( Client client,
std::string  uri,
const AttachmentPoolOptions options = {} 
)
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.

◆ ~AttachmentPool()

AttachmentPool::~AttachmentPool ( )
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.

Member Function Documentation

◆ acquire()

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.

◆ availableCount()

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.

◆ close()

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.

◆ getClient()

Client & fbcpp::AttachmentPool::getClient ( )
inlinenoexcept

Returns the Client object reference used to create this AttachmentPool object.

Definition at line 364 of file AttachmentPool.h.

◆ getOptions()

const AttachmentPoolOptions & fbcpp::AttachmentPool::getOptions ( ) const
inlinenoexcept

Returns the options used to create this AttachmentPool object.

Definition at line 380 of file AttachmentPool.h.

◆ getUri()

const std::string & fbcpp::AttachmentPool::getUri ( ) const
inlinenoexcept

Returns the database URI this pool connects to.

Definition at line 372 of file AttachmentPool.h.

◆ inUseCount()

std::size_t AttachmentPool::inUseCount ( )

Returns the number of connections currently leased out by the pool.

Definition at line 113 of file AttachmentPool.cpp.

◆ size()

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.

◆ tryAcquire()

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.

Friends And Related Symbol Documentation

◆ PooledAttachment

friend class PooledAttachment
friend

Definition at line 339 of file AttachmentPool.h.


The documentation for this class was generated from the following files: