diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-01-23 02:50:45 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-01-23 02:53:31 -0500 |
commit | 4f5b88015724bd866564b95592296c7ea28a46cb (patch) | |
tree | 8d74dfe506a0289da16e984213535cb96d2f738e /client/parallel.cpp | |
parent | 2c5795d6207ff16ea44e27bf55e8c3729e1060ed (diff) | |
download | mongo-4f5b88015724bd866564b95592296c7ea28a46cb.tar.gz |
ability to select Connection to use for Future
Diffstat (limited to 'client/parallel.cpp')
-rw-r--r-- | client/parallel.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/client/parallel.cpp b/client/parallel.cpp index 14f0fa450d2..27cbec1eb4c 100644 --- a/client/parallel.cpp +++ b/client/parallel.cpp @@ -467,10 +467,11 @@ namespace mongo { // ---- Future ----- // ----------------- - Future::CommandResult::CommandResult( const string& server , const string& db , const BSONObj& cmd ) { + Future::CommandResult::CommandResult( const string& server , const string& db , const BSONObj& cmd , DBClientBase * conn ) { _server = server; _db = db; _cmd = cmd; + _conn = conn; _done = false; } @@ -484,9 +485,19 @@ namespace mongo { setThreadName( "future" ); try { - ScopedDbConnection conn( res->_server ); + DBClientBase * conn = res->_conn; + + scoped_ptr<ScopedDbConnection> myconn; + if ( ! conn ){ + myconn.reset( new ScopedDbConnection( res->_server ) ); + conn = myconn->get(); + } + res->_ok = conn->runCommand( res->_db , res->_cmd , res->_res ); - conn.done(); + + if ( myconn ) + myconn->done(); + } catch ( std::exception& e ) { error() << "Future::commandThread exception: " << e.what() << endl; @@ -495,8 +506,8 @@ namespace mongo { res->_done = true; } - shared_ptr<Future::CommandResult> Future::spawnCommand( const string& server , const string& db , const BSONObj& cmd ) { - shared_ptr<Future::CommandResult> res (new Future::CommandResult( server , db , cmd )); + shared_ptr<Future::CommandResult> Future::spawnCommand( const string& server , const string& db , const BSONObj& cmd , DBClientBase * conn ) { + shared_ptr<Future::CommandResult> res (new Future::CommandResult( server , db , cmd , conn )); res->_thr.reset( new boost::thread( boost::bind(Future::commandThread, res) ) ); return res; |