QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
|
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 () |
T | acquireConnection (const QString &connInfo, int timeout=-1, bool requestMayBeNested=false, QgsFeedback *feedback=nullptr) |
Try to acquire a connection for a maximum of timeout milliseconds. 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 |
Template class responsible for keeping a pool of open connections.
This is desired to avoid the overhead of creation of new connection every time.
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.
Definition at line 271 of file qgsconnectionpool.h.
typedef QMap<QString, T_Group *> QgsConnectionPool< T, T_Group >::T_Groups |
Definition at line 275 of file qgsconnectionpool.h.
|
inlinevirtual |
Definition at line 277 of file qgsconnectionpool.h.
|
inline |
Try to acquire a connection for a maximum of timeout milliseconds.
If timeout is a negative value the calling thread will be blocked until a connection becomes available. This is the default behavior.
The optional feedback argument can be used to cancel the request before the connection is acquired.
nullptr
if unsuccessful Definition at line 298 of file qgsconnectionpool.h.
|
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 349 of file qgsconnectionpool.h.
|
inline |
Release an existing connection so it will get back into the pool and can be reused.
Definition at line 331 of file qgsconnectionpool.h.
|
protected |
Definition at line 359 of file qgsconnectionpool.h.
|
protected |
Definition at line 360 of file qgsconnectionpool.h.