te::pgis::ConnectionPool Class Reference

This class implements a connection pool for the PostGIS driver. More...

#include <ConnectionPool.h>

Inheritance diagram for te::pgis::ConnectionPool:
te::da::AbstractConnectionPool

Public Member Functions

void finalize ()
 It closes all connections and clears all resources managed by the pool. More...
 
ConnectiongetConnection ()
 It returns a connection from the pool. More...
 
te::pgis::DataSourcegetDataSource () const
 
std::size_t getInitialPoolSize () const
 It returns the initial number of connections opened by the pool at its startup. More...
 
unsigned int getMaxIdleTime () const
 It returns the maximum idle time in seconds that a connection can be maintained in the pool without being used. More...
 
std::size_t getMaxPoolSize () const
 It returns the maximum number of connections managed by the pool. More...
 
std::size_t getMinPoolSize () const
 It returns the minimum number of connections managed by the pool. More...
 
std::size_t getPoolSize () const
 It returns the number of connections in the pool. More...
 
void idle ()
 It releases the connections that are not in use for a long time. More...
 
void initialize ()
 It initializes the connections to be managed by the pool. More...
 
bool isInitialized () const
 It returns true if the connection pool is initialized, otherwise it returns false. More...
 
bool isValid () const
 It checks if all the connections in the pool are valid (the communication channel is ok). More...
 
void release (Connection *conn)
 It brings the informed connection back to the pool. More...
 
void setInitialPoolSize (std::size_t size)
 It sets the initial number of connections opened by the pool at its startup. More...
 
void setMaxIdleTime (unsigned int t)
 It sets the maximum idle time that a connection can be maintained in the pool without being used. More...
 
void setMaxPoolSize (std::size_t size)
 It sets the maximum number of connections managed by the pool. More...
 
void setMinPoolSize (std::size_t size)
 It sets the minimum number of connections managed by the pool. More...
 

Private Member Functions

 ConnectionPool (DataSource *ds)
 It creates a new connection pool for the database informed. More...
 
 ~ConnectionPool ()
 Destructor. More...
 

Private Attributes

ConnectionPoolImpl * m_pImpl
 A pointer to the pool implementation. More...
 

Friends

class DataSource
 

Detailed Description

This class implements a connection pool for the PostGIS driver.

See also
AbstractConnectionPool, ConnectionPoolManager, Connection

Definition at line 48 of file ConnectionPool.h.

Constructor & Destructor Documentation

te::pgis::ConnectionPool::ConnectionPool ( DataSource ds)
private

It creates a new connection pool for the database informed.

Parameters
dsThe data source using this pool.
te::pgis::ConnectionPool::~ConnectionPool ( )
private

Destructor.

It will automatically close all connections to a PostgreSQL database.

Member Function Documentation

void te::pgis::ConnectionPool::finalize ( )
virtual

It closes all connections and clears all resources managed by the pool.

Exceptions
ExceptionIt may throws an exception if there is a connection in use or if it is not possible to stop the pool.
Note
Successive calls won't have effect.
Thread-safe.

Implements te::da::AbstractConnectionPool.

Connection* te::pgis::ConnectionPool::getConnection ( )

It returns a connection from the pool.

Returns
A connection if one is available or an exception will be raised.
Exceptions
ExceptionIt throws an exception if it is not possible to get a connection.
Warning
You must call the release() method after using the connection to assure that the connection was returned to the pool. This approach will increase concurrency in the connection.
Note
PostGIS extended method.
te::pgis::DataSource* te::pgis::ConnectionPool::getDataSource ( ) const
std::size_t te::pgis::ConnectionPool::getInitialPoolSize ( ) const
virtual

It returns the initial number of connections opened by the pool at its startup.

Returns
The initial number of connections opened by the pool at its startup.
Note
Thread-safe.

Implements te::da::AbstractConnectionPool.

unsigned int te::pgis::ConnectionPool::getMaxIdleTime ( ) const

It returns the maximum idle time in seconds that a connection can be maintained in the pool without being used.

Returns
The maximum idle time that a connection can be maintained in the pool without being used.
Note
Thread-safe.
PostGIS extended method.
std::size_t te::pgis::ConnectionPool::getMaxPoolSize ( ) const
virtual

It returns the maximum number of connections managed by the pool.

Returns
The maximum number of connections managed by the pool.
Note
Thread-safe.

Implements te::da::AbstractConnectionPool.

std::size_t te::pgis::ConnectionPool::getMinPoolSize ( ) const
virtual

It returns the minimum number of connections managed by the pool.

Returns
The minimum number of connections managed by the pool.
Note
Thread-safe.

Implements te::da::AbstractConnectionPool.

std::size_t te::pgis::ConnectionPool::getPoolSize ( ) const
virtual

It returns the number of connections in the pool.

Returns
The number of the connections in the pool.
Note
Thread-safe.

Implements te::da::AbstractConnectionPool.

void te::pgis::ConnectionPool::idle ( )
virtual

It releases the connections that are not in use for a long time.

This method will try to keep the pool with the minimum number of opened connections. It will be invoked by the connection pool manager when its thread wakeup. It must check the idle connections and must destroy them.

Note
Thread-safe.

Implements te::da::AbstractConnectionPool.

void te::pgis::ConnectionPool::initialize ( )
virtual

It initializes the connections to be managed by the pool.

Exceptions
ExceptionIt throws an exception if it is not possible to initialize the pool.
Note
Successive calls won't have effect.
Thread-safe.

Implements te::da::AbstractConnectionPool.

bool te::pgis::ConnectionPool::isInitialized ( ) const
virtual

It returns true if the connection pool is initialized, otherwise it returns false.

Returns
True if the connection pool is initialized, otherwise it returns false.
Note
Thread-safe.

Implements te::da::AbstractConnectionPool.

bool te::pgis::ConnectionPool::isValid ( ) const
virtual

It checks if all the connections in the pool are valid (the communication channel is ok).

Returns
It returns true if all the connections are valid (the communication channel is ok), otherwise it returns false.
Note
Thread-safe.

Implements te::da::AbstractConnectionPool.

void te::pgis::ConnectionPool::release ( Connection conn)

It brings the informed connection back to the pool.

Parameters
connThe connection to be put back the pool.
Note
PostGIS extended method.
void te::pgis::ConnectionPool::setInitialPoolSize ( std::size_t  size)
virtual

It sets the initial number of connections opened by the pool at its startup.

Parameters
sizeIt specifies the initial number of connections that must be opened by the pool at its startup.
Note
The pool must be reset before the changes take effect.
Thread-safe.

Implements te::da::AbstractConnectionPool.

void te::pgis::ConnectionPool::setMaxIdleTime ( unsigned int  t)

It sets the maximum idle time that a connection can be maintained in the pool without being used.

Parameters
tIt specifies the maximum idle time in seconds that a connection can be maintained in the pool without being used.
Note
A zero value indicates that the connections will not be removed from the pool when it is not being used for a while.
Thread-safe.
PostGIS extended method.
void te::pgis::ConnectionPool::setMaxPoolSize ( std::size_t  size)
virtual

It sets the maximum number of connections managed by the pool.

Parameters
sizeThe maximum number of connections that the pool must manage.
Note
The pool must be reset before the changes take effect.
Thread-safe.

Implements te::da::AbstractConnectionPool.

void te::pgis::ConnectionPool::setMinPoolSize ( std::size_t  size)
virtual

It sets the minimum number of connections managed by the pool.

Parameters
sizeThe minimum number of connections that the pool must manage.
Note
The pool must be reset before the changes take effect.
Thread-safe.

Implements te::da::AbstractConnectionPool.

Friends And Related Function Documentation

friend class DataSource
friend

Definition at line 150 of file ConnectionPool.h.

Member Data Documentation

ConnectionPoolImpl* te::pgis::ConnectionPool::m_pImpl
private

A pointer to the pool implementation.

Definition at line 146 of file ConnectionPool.h.


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