Session SessionPool::get() { Poco::Mutex::ScopedLock lock(_mutex); if (_shutdown) throw InvalidAccessException("Session pool has been shut down."); purgeDeadSessions(); if (_idleSessions.empty()) { if (_nSessions < _maxSessions) { Session newSession(SessionFactory::instance().create(_connector, _connectionString)); applySettings(newSession.impl()); customizeSession(newSession); PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl())); _idleSessions.push_front(pHolder); ++_nSessions; } else throw SessionPoolExhaustedException(_connector); } PooledSessionHolderPtr pHolder(_idleSessions.front()); PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder)); _activeSessions.push_front(pHolder); _idleSessions.pop_front(); return Session(pPSI); }
Session SessionPool::get() { Poco::FastMutex::ScopedLock lock(_mutex); purgeDeadSessions(); if (_idleSessions.empty()) { if (_nSessions < _maxSessions) { Session newSession(SessionFactory::instance().create(_sessionKey, _connectionString)); PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl())); _idleSessions.push_front(pHolder); ++_nSessions; } else throw SessionPoolExhaustedException(_sessionKey, _connectionString); } PooledSessionHolderPtr pHolder(_idleSessions.front()); PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder)); _activeSessions.push_front(pHolder); _idleSessions.pop_front(); return Session(pPSI); }