0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
This commit is contained in:
Dwight 2010-10-28 10:38:36 -04:00
parent 2884252fef
commit 681a993dd1

View File

@ -141,17 +141,21 @@ namespace mongo {
};
/** Use to get a connection from the pool. On exceptions things
clean up nicely.
clean up nicely (i.e. the socket gets closed automatically when the
scopeddbconnection goes out of scope).
*/
class ScopedDbConnection : public AScopedConnection {
public:
/** the main constructor you want to use
throws UserException if can't connect
*/
explicit ScopedDbConnection(const string& host) : _host(host), _conn( pool.get(host) ) {}
ScopedDbConnection() : _host( "" ) , _conn(0) {}
/* @param conn - bind to an existing connection */
ScopedDbConnection(const string& host, DBClientBase* conn ) : _host( host ) , _conn( conn ) {}
/** throws UserException if can't connect */
explicit ScopedDbConnection(const string& host) : _host(host), _conn( pool.get(host) ) {}
/** throws UserException if can't connect */
explicit ScopedDbConnection(const ConnectionString& url ) : _host(url.toString()), _conn( pool.get(url) ) {}