16 #ifndef QGSCONNECTIONPOOL_H
17 #define QGSCONNECTIONPOOL_H
19 #include <QCoreApplication>
30 #define CONN_POOL_MAX_CONCURRENT_CONNS 4
31 #define CONN_POOL_EXPIRATION_TIME 60 // in seconds
74 qgsConnectionPool_ConnectionDestroy( item.
c );
87 if ( !
conns.isEmpty() )
92 if (
conns.isEmpty() )
95 QMetaObject::invokeMethod(
expirationTimer->parent(),
"stopExpirationTimer" );
103 qgsConnectionPool_ConnectionCreate(
connInfo, c );
125 QMetaObject::invokeMethod(
expirationTimer->parent(),
"startExpirationTimer" );
139 QObject::connect(
expirationTimer, SIGNAL( timeout() ), parent, SLOT( handleConnectionExpired() ) );
142 parent->moveToThread( qApp->thread() );
149 QTime now = QTime::currentTime();
153 for (
int i = 0; i <
conns.count(); ++i )
156 toDelete.append( i );
160 for (
int j = toDelete.count() - 1; j >= 0; --j )
162 int index = toDelete[j];
163 qgsConnectionPool_ConnectionDestroy(
conns[index].c );
164 conns.remove( index );
167 if (
conns.isEmpty() )
198 template <
typename T,
typename T_Group>
210 typename T_Groups::iterator it =
mGroups.find( connInfo );
213 it =
mGroups.insert( connInfo,
new T_Group( connInfo ) );
215 T_Group* group = *it;
218 return group->acquire();
225 typename T_Groups::iterator it =
mGroups.find( qgsConnectionPool_ConnectionToName( conn ) );
226 Q_ASSERT( it !=
mGroups.end() );
227 T_Group* group = *it;
230 group->release( conn );
241 #endif // QGSCONNECTIONPOOL_H