PooledConnection* ConnectionPool::getOrDefault(const char* policyName, LMREG::CppTable* params) { if(!m_settings.empty()) { return this->get(policyName, params); } { PooledConnection* cnn = NULL; JG_S::KAutoThreadMutex mx(m_mx); ConnectionSetting* cnnSetting = m_settings.defaultConnection(); if(!cnnSetting) return NULL; ConnectionList& lst = m_cnnMap[m_settings.defaultName()]; cnn = lst.pop_front(); if(!cnn) { cnn = PooledConnection::Alloc(); cnn->reset(); cnn->m_setting = cnnSetting; } if(!cnn->keepAlive()) { this->release(cnn); return NULL; } return cnn; } }
PooledConnection* ConnectionPool::get(const char* policyName, LMREG::CppTable* params) { PooledConnection* cnn = NULL; { JG_S::KAutoThreadMutex mx(m_mx); ConnectionSetting* cnnSetting = (ConnectionSetting*)m_settings.callPolicy(policyName, *params); if(!cnnSetting) return NULL; const char* cnnName = cnnSetting->m_name.c_str(); ConnectionList& lst = m_cnnMap[cnnName]; cnn = lst.pop_front(); if(!cnn) { cnn = PooledConnection::Alloc(); cnn->reset(); cnn->m_setting = cnnSetting; } } if(!cnn->keepAlive()) { this->release(cnn); return NULL; } return cnn; }