本文整理汇总了C++中DBConnectionPool::onHandedOut方法的典型用法代码示例。如果您正苦于以下问题:C++ DBConnectionPool::onHandedOut方法的具体用法?C++ DBConnectionPool::onHandedOut怎么用?C++ DBConnectionPool::onHandedOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnectionPool
的用法示例。
在下文中一共展示了DBConnectionPool::onHandedOut方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
DBClientBase * get( const string& addr , const string& ns ) {
_check( ns );
Status* s = _getStatus( addr );
auto_ptr<DBClientBase> c; // Handles cleanup if there's an exception thrown
if ( s->avail ) {
c.reset( s->avail );
s->avail = 0;
shardConnectionPool.onHandedOut( c.get() ); // May throw an exception
} else {
c.reset( shardConnectionPool.get( addr ) );
s->created++; // After, so failed creation doesn't get counted
}
return c.release();
}
示例2: get
DBClientBase * get( const string& addr , const string& ns, bool ignoreDirect = false ) {
_check( ns );
// Determine if non-shard conn is RS member for warning
// All shards added to _hosts if not present in _check()
if( ( logLevel >= 1 || ! printedShardConnWarning ) && ! ignoreDirect && _hosts.find( addr ) == _hosts.end() ){
vector<Shard> all;
Shard::getAllShards( all );
bool isRSMember = false;
string parentShard;
for ( unsigned i = 0; i < all.size(); i++ ) {
string connString = all[i].getConnString();
if( connString.find( addr ) != string::npos && connString.find( '/' ) != string::npos ){
isRSMember = true;
parentShard = connString;
break;
}
}
if( isRSMember ){
printedShardConnWarning = true;
warning() << "adding shard sub-connection " << addr << " (parent " << parentShard << ") as sharded, this is safe but unexpected" << endl;
printStackTrace();
}
}
Status* &s = _hosts[addr];
if ( ! s )
s = new Status();
if ( s->avail ) {
DBClientBase* c = s->avail;
s->avail = 0;
shardConnectionPool.onHandedOut( c );
return c;
}
s->created++;
return shardConnectionPool.get( addr );
}
示例3: get
DBClientBase * get( const string& addr , const string& ns ) {
_check( ns );
Status* &s = _hosts[addr];
if ( ! s )
s = new Status();
auto_ptr<DBClientBase> c; // Handles cleanup if there's an exception thrown
if ( s->avail ) {
c.reset( s->avail );
s->avail = 0;
shardConnectionPool.onHandedOut( c.get() ); // May throw an exception
} else {
s->created++;
c.reset( shardConnectionPool.get( addr ) );
}
if ( !noauth ) {
c->setAuthenticationTable( ClientBasic::getCurrent()->getAuthenticationInfo()->
getAuthTable() );
}
return c.release();
}