MongoDB  2.7.0
Public Member Functions | Static Public Member Functions | List of all members
mongo::ScopedDbConnection Class Reference

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

#include <connpool.h>

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

Public Member Functions

 ScopedDbConnection (const string &host, double socketTimeout=0)
 the main constructor you want to use throws UserException if can't connect
 
 ScopedDbConnection (const ConnectionString &host, double socketTimeout=0)
 
 ScopedDbConnection (const string &host, DBClientBase *conn, double socketTimeout=0)
 
DBClientBaseoperator-> ()
 get the associated connection object
 
DBClientBaseconn ()
 get the associated connection object
 
DBClientBaseget ()
 get the associated connection object
 
bool ok () const
 
string getHost () const
 
void kill ()
 Force closure of the connection. More...
 
void done ()
 Call this when you are done with the connection. More...
 

Static Public Member Functions

static void clearPool ()
 
- Static Public Member Functions inherited from mongo::AScopedConnection
static int getNumConnections ()
 

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 ( )
inlinevirtual

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.

bool mongo::ScopedDbConnection::ok ( ) const
inlinevirtual
Returns
true iff this has a connection to the db

Implements mongo::AScopedConnection.


The documentation for this class was generated from the following files: