Skip to content

Commit

Permalink
Add QgsApplication::maxConcurrentConnectionsPerPool()
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 8, 2018
1 parent bef52f3 commit 955323f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_generated/qgsapplication.sip.in
Expand Up @@ -797,6 +797,13 @@ Do not include generated variables (like system name, user name etc.)
Set a single custom expression variable.

.. versionadded:: 3.0
%End

int maxConcurrentConnectionsPerPool() const;
%Docstring
The maximum number of concurrent connections per connections pool

.. versionadded:: 3.4
%End

%If (ANDROID)
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsapplication.cpp
Expand Up @@ -85,6 +85,8 @@
#include <cpl_conv.h> // for setting gdal options
#include <sqlite3.h>

#define CONN_POOL_MAX_CONCURRENT_CONNS 6

QObject *ABISYM( QgsApplication::mFileOpenEventReceiver );
QStringList ABISYM( QgsApplication::mFileOpenEventList );
QString ABISYM( QgsApplication::mPrefixPath );
Expand Down Expand Up @@ -1461,6 +1463,10 @@ void QgsApplication::setCustomVariable( const QString &name, const QVariant &val
emit instance()->customVariablesChanged();
}

int QgsApplication::maxConcurrentConnectionsPerPool() const
{
return CONN_POOL_MAX_CONCURRENT_CONNS;
}

QString QgsApplication::nullRepresentation()
{
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -732,6 +732,13 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
static void setCustomVariable( const QString &name, const QVariant &value );

/**
* The maximum number of concurrent connections per connections pool
*
* \since QGIS 3.4
*/
int maxConcurrentConnectionsPerPool() const;

#ifdef SIP_RUN
SIP_IF_FEATURE( ANDROID )
//dummy method to workaround sip generation issue
Expand Down
6 changes: 2 additions & 4 deletions src/core/qgsconnectionpool.h
Expand Up @@ -19,6 +19,7 @@
#define SIP_NO_FILE

#include "qgis.h"
#include "qgsapplication.h"
#include <QCoreApplication>
#include <QMap>
#include <QMutex>
Expand All @@ -29,7 +30,6 @@
#include <QThread>


#define CONN_POOL_MAX_CONCURRENT_CONNS 6
#define CONN_POOL_EXPIRATION_TIME 60 // in seconds


Expand Down Expand Up @@ -59,8 +59,6 @@ class QgsConnectionPoolGroup
{
public:

static const int MAX_CONCURRENT_CONNECTIONS;

struct Item
{
T c;
Expand All @@ -69,7 +67,7 @@ class QgsConnectionPoolGroup

QgsConnectionPoolGroup( const QString &ci )
: connInfo( ci )
, sem( CONN_POOL_MAX_CONCURRENT_CONNS )
, sem( QgsApplication::instance()->maxConcurrentConnectionsPerPool() )
{
}

Expand Down

0 comments on commit 955323f

Please sign in to comment.