mongo::ScopedDbConnection Class Reference

Use to get a connection from the pool. More...

#include <connpool.h>

Inheritance diagram for mongo::ScopedDbConnection:
mongo::AScopedConnection

List of all members.

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)
DBClientBaseoperator-> ()
 get the associated connection object
DBClientBaseconn ()
 get the associated connection object
DBClientBaseget ()
 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.
ScopedDbConnectionsteal ()

Detailed Description

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).


Member Function Documentation

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.


The documentation for this class was generated from the following files:
Generated on Wed Sep 14 01:46:38 2011 for MongoDB by  doxygen 1.6.3