Use to get a connection from the pool. More...
#include <connpool.h>
Public Member Functions | |
| ScopedDbConnection (const string &host) | |
| the main constructor you want to use throws UserException if can't connect | |
| ScopedDbConnection (const string &host, DBClientBase *conn) | |
| ScopedDbConnection (const ConnectionString &url) | |
| throws UserException if can't connect | |
| ScopedDbConnection (const Shard &shard) | |
| throws UserException if can't connect | |
| ScopedDbConnection (const Shard *shard) | |
| DBClientBase * | operator-> () |
| get the associated connection object | |
| DBClientBase & | conn () |
| get the associated connection object | |
| DBClientBase * | get () |
| get the associated connection object | |
| string | getHost () const |
| void | kill () |
| Force closure of the connection. | |
| void | done () |
| Call this when you are done with the connection. | |
| ScopedDbConnection * | steal () |
Use to get a connection from the pool.
On exceptions things clean up nicely (i.e. the socket gets closed automatically when the scopeddbconnection goes out of scope).
| void mongo::ScopedDbConnection::done | ( | ) | [inline, virtual] |
Call this when you are done with the connection.
If you do not call done() before this object goes out of scope, we can't be sure we fully read all expected data of a reply on the socket. so we don't try to reuse the connection in that situation.
Implements mongo::AScopedConnection.
| void mongo::ScopedDbConnection::kill | ( | ) | [inline] |
Force closure of the connection.
You should call this if you leave it in a bad state. Destructor will do this too, but it is verbose.
1.6.3