QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Types | Public Member Functions | Protected Attributes | List of all members
QgsConnectionPool< T, T_Group > Class Template Reference

Template class responsible for keeping a pool of open connections. More...

#include <qgsconnectionpool.h>

Public Types

typedef QMap< QString, T_Group * > T_Groups
 

Public Member Functions

virtual ~QgsConnectionPool ()
 
acquireConnection (const QString &connInfo)
 Try to acquire a connection: if no connections are available, the thread will get blocked. More...
 
void invalidateConnections (const QString &connInfo)
 Invalidates all connections to the specified resource. More...
 
void releaseConnection (T conn)
 Release an existing connection so it will get back into the pool and can be reused. More...
 

Protected Attributes

T_Groups mGroups
 
QMutex mMutex
 

Detailed Description

template<typename T, typename T_Group>
class QgsConnectionPool< T, T_Group >

Template class responsible for keeping a pool of open connections.

This is desired to avoid the overhead of creation of new connection everytime.

The methods are thread safe.

The connection pool has a limit on maximum number of concurrent connections (per server), once the limit is reached, the acquireConnection() function will block. All connections that have been acquired must be then released with releaseConnection() function.

When the connections are not used for some time, they will get closed automatically to save resources.

Note
not available in Python bindings

Definition at line 236 of file qgsconnectionpool.h.

Member Typedef Documentation

◆ T_Groups

template<typename T , typename T_Group >
typedef QMap<QString, T_Group*> QgsConnectionPool< T, T_Group >::T_Groups

Definition at line 240 of file qgsconnectionpool.h.

Constructor & Destructor Documentation

◆ ~QgsConnectionPool()

template<typename T , typename T_Group >
virtual QgsConnectionPool< T, T_Group >::~QgsConnectionPool ( )
inlinevirtual

Definition at line 242 of file qgsconnectionpool.h.

Member Function Documentation

◆ acquireConnection()

template<typename T , typename T_Group >
T QgsConnectionPool< T, T_Group >::acquireConnection ( const QString connInfo)
inline

Try to acquire a connection: if no connections are available, the thread will get blocked.

Returns
initialized connection or null on error

Definition at line 255 of file qgsconnectionpool.h.

◆ invalidateConnections()

template<typename T , typename T_Group >
void QgsConnectionPool< T, T_Group >::invalidateConnections ( const QString connInfo)
inline

Invalidates all connections to the specified resource.

The internal state of certain handles (for instance OGR) are altered when a dataset is modified. Consquently, all open handles need to be invalidated when such datasets are changed to ensure the handles are refreshed. See the OGR provider for an example where this is needed.

Definition at line 286 of file qgsconnectionpool.h.

◆ releaseConnection()

template<typename T , typename T_Group >
void QgsConnectionPool< T, T_Group >::releaseConnection ( conn)
inline

Release an existing connection so it will get back into the pool and can be reused.

Definition at line 270 of file qgsconnectionpool.h.

Member Data Documentation

◆ mGroups

template<typename T , typename T_Group >
T_Groups QgsConnectionPool< T, T_Group >::mGroups
protected

Definition at line 296 of file qgsconnectionpool.h.

◆ mMutex

template<typename T , typename T_Group >
QMutex QgsConnectionPool< T, T_Group >::mMutex
protected

Definition at line 297 of file qgsconnectionpool.h.


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