Loading...
Searching...
No Matches
mongocxx::v_noabi::pool Class Reference

`#include <mongocxx/v_noabi/mongocxx/pool.hpp>`

## Description

A pool of reusable client objects connected to the same MongoDB topology.

Important
  This class does NOT implement Connection Monitoring and Pooling (MongoDB Specifications).

For interoperability with other MongoDB drivers, the minimum and maximum number of connections in the pool is configured using the 'minPoolSize' and 'maxPoolSize' connection string options.

See also
  - https://www.mongodb.com/docs/manual/reference/connection-string/#connection-string-options

Remarks
  When connecting to a replica set, it is much more efficient to use a pool as opposed to manually constructing `client` objects. The pool will use a single background thread per server to monitor the topology of the replica set, all of which are shared between the client objects created by the pool. A standalone client will instead "stop the world" every 60 seconds to check the status of the cluster. Because of this, if multiple threads are available, a connection pool should be used even if the application itself is single-threaded.

## Classes

class | entry
| An owning handle to a client obtained from a pool. More...

## Public Member Functions

| pool (v_noabi::uri const &mongodb_uri={}, v_noabi::options::pool const &options={})
| Creates a pool associated with a connection string.
| ~pool ()=default
| Destroys a pool.
entry | acquire ()
| Acquires a client from the pool. The calling thread will block until a connection is available.
bsoncxx::v_noabi::stdx::optional< entry > | try_acquire ()
| Acquires a client from the pool. This method will return immediately, but may return a disengaged optional if a client is not available.

## Constructor & Destructor Documentation

## pool()

mongocxx::v_noabi::pool::pool | ( | v_noabi::uri const & | mongodb_uri = {},
|  | v_noabi::options::pool const & | options = {} )

explicit

Creates a pool associated with a connection string.

Parameters

  mongodb_uri | A MongoDB URI representing the connection parameters
  options | Options to use when connecting to the MongoDB deployment.

Exceptions

  mongocxx::v_noabi::exception | if invalid options are provided (whether from the URI or provided client options).

## ~pool()

mongocxx::v_noabi::pool::~pool | ( |  | ) |

default

Destroys a pool.

## Member Function Documentation

## acquire()

entry mongocxx::v_noabi::pool::acquire | ( |  | ) |

Acquires a client from the pool. The calling thread will block until a connection is available.

## try_acquire()

bsoncxx::v_noabi::stdx::optional< entry > mongocxx::v_noabi::pool::try_acquire | ( |  | ) |

Acquires a client from the pool. This method will return immediately, but may return a disengaged optional if a client is not available.

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

- mongocxx/v_noabi/mongocxx/pool.hpp