lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
lintel::db::ConnectionPool::Lease Class Reference

#include <ConnectionPool.h>

Public Member Functions

 Lease ()=default
 
 Lease (const Lease &)=delete
 
Lease & operator= (const Lease &)=delete
 
 Lease (Lease &&other) noexcept
 
Lease & operator= (Lease &&other) noexcept
 
 ~Lease ()
 
Connection & connection () const
 
bool valid () const
 

Friends

class ConnectionPool
 

Detailed Description

RAII handle on a pooled connection.

Movable but not copyable: a lease belongs to the scope that acquired it and returns the connection on destruction (also while an exception unwinds). A lease that wanders out of its scope is a programming error, which is why copying is deleted; acquire() returns the lease by value through guaranteed copy elision.

Constructor & Destructor Documentation

◆ Lease() [1/3]

lintel::db::ConnectionPool::Lease::Lease ( )
default

Construct an empty lease that holds no connection.

◆ Lease() [2/3]

lintel::db::ConnectionPool::Lease::Lease ( const Lease &  )
delete

◆ Lease() [3/3]

lintel::db::ConnectionPool::Lease::Lease ( Lease &&  other)
noexcept
Parameters
otherlease to move from; other is emptied

◆ ~Lease()

lintel::db::ConnectionPool::Lease::~Lease ( )

Release the held connection back to the pool.

Member Function Documentation

◆ connection()

Connection & lintel::db::ConnectionPool::Lease::connection ( ) const
Returns
the leased connection
Exceptions
SQLExceptionif the lease is empty (moved-from or default-constructed)

◆ operator=() [1/2]

Lease & lintel::db::ConnectionPool::Lease::operator= ( const Lease &  )
delete

◆ operator=() [2/2]

Lease & lintel::db::ConnectionPool::Lease::operator= ( Lease &&  other)
noexcept
Parameters
otherlease to move from; a held connection is released first
Returns
this lease

◆ valid()

bool lintel::db::ConnectionPool::Lease::valid ( ) const
inline
Returns
true if the lease currently owns a connection

Friends And Related Symbol Documentation

◆ ConnectionPool


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