mongo::ScopedConn Class Reference

#include <connections.h>

List of all members.

Classes

struct  X

Public Member Functions

unsigned long long count (const string &ns)
BSONObj findOne (const string &ns, const Query &q, const BSONObj *fieldsToReturn=0, int queryOptions=0)
bool runCommand (const string &dbname, const BSONObj &cmd, BSONObj &info, int options=0)
 ScopedConn (string hostport)
void setTimeout (double to)
 ~ScopedConn ()

Private Types

typedef map< string,
ScopedConn::X * > 
M

Private Member Functions

DBClientConnectionconn ()

Private Attributes

auto_ptr< scoped_lockconnLock
struct mongo::ScopedConn::Xx

Static Private Attributes

static M_map
static mongo::mutex mapMutex

Detailed Description

here we keep a single connection (with reconnect) for a set of hosts, one each, and allow one user at a time per host. if in use already for that host, we block. so this is an easy way to keep a 1-deep pool of connections that many threads can share.

thread-safe.

Example: { ScopedConn c("foo.acme.com:9999"); c->runCommand(...); }

throws exception on connect error (but fine to try again later with a new scopedconn object for same host).

Definition at line 43 of file connections.h.


Member Typedef Documentation

typedef map<string,ScopedConn::X*> mongo::ScopedConn::M [private]

Definition at line 77 of file connections.h.


Constructor & Destructor Documentation

mongo::ScopedConn::ScopedConn ( string  hostport  )  [inline]

throws assertions if connect failure etc.

Definition at line 82 of file connections.h.

mongo::ScopedConn::~ScopedConn (  )  [inline]

Definition at line 111 of file connections.h.


Member Function Documentation

DBClientConnection* mongo::ScopedConn::conn (  )  [inline, private]

Definition at line 79 of file connections.h.

unsigned long long mongo::ScopedConn::count ( const string &  ns  )  [inline]

Definition at line 57 of file connections.h.

BSONObj mongo::ScopedConn::findOne ( const string &  ns,
const Query q,
const BSONObj fieldsToReturn = 0,
int  queryOptions = 0 
) [inline]

Definition at line 60 of file connections.h.

bool mongo::ScopedConn::runCommand ( const string &  dbname,
const BSONObj cmd,
BSONObj info,
int  options = 0 
) [inline]

Definition at line 54 of file connections.h.

void mongo::ScopedConn::setTimeout ( double  to  )  [inline]

Definition at line 63 of file connections.h.


Member Data Documentation

M& mongo::ScopedConn::_map [static, private]

Definition at line 78 of file connections.h.

Definition at line 68 of file connections.h.

Definition at line 69 of file connections.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


mongodb
Author(s): Nate Koenig
autogenerated on Fri Jan 11 12:15:57 2013