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 3, 2018
1 parent 92ace51 commit 9d5f6f3
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 9d5f6f3

Please sign in to comment.