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

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

## Description

A thread-safe pool of client objects.

Important
  This interface does NOT fully conform to the CMAP specification!

See also
  - mongoc_client_pool_t (mongoc)
  - Connection Monitoring and Pooling (MongoDB Specifications)
  - Connection Pool Overview (MongoDB Manual)

## Classes

class | entry
| A handle to a client object owned by an associated pool. More...
class | options
| Options for mongocxx::v1::pool. More...

## Public Types

enum class | errc
| Errors codes which may be returned by mongocxx::v1::pool. More...

## Public Member Functions

| pool ()
| Initialize this pool with default URI options.
| pool (pool &&other) noexcept
| Move constructor.
| pool (pool const &other)=delete
| This class is not copyable.
| ~pool ()
| Destroy this object.
entry | acquire ()
| Return a client object associated with this pool.
| operator bool () const
| Return true when *this is NOT in an assign-or-destroy-only state.
pool & | operator= (pool &&other) noexcept
| Move assignment.
pool & | operator= (pool const &other)=delete
| This class is not copyable.
bsoncxx::v1::stdx::optional< entry > | try_acquire ()
| Return a client object associated with this pool.
| pool (v1::uri const &uri, options opts)
| Initialize this pool with the given URI.
| pool (v1::uri const &uri)
| Initialize this pool with the given URI.

## Static Public Member Functions

static std::error_category const & | error_category ()
| The error category for mongocxx::v1::pool::errc.

## Friends

std::error_code | make_error_code (errc v)
| Support implicit conversion to std::error_code.

## Member Enumeration Documentation

## errc

enum class mongocxx::v1::pool::errc

strong

Errors codes which may be returned by mongocxx::v1::pool.

Enumerator
zero | Zero.
wait_queue_timeout | Failed to acquire a client object due to "waitQueueTimeoutMS".

## Constructor & Destructor Documentation

## ~pool()

mongocxx::v1::pool::~pool | ( |  | ) |

Destroy this object.

Warning
  Invalidates all entries and clients associated with this pool.

## pool() [1/5]

mongocxx::v1::pool::pool | ( | pool && | other | ) |

noexcept

Move constructor.

Postconditions:
  - other is in an assign-or-destroy-only state.

## pool() [2/5]

mongocxx::v1::pool::pool | ( | pool const & | other | ) |

delete

This class is not copyable.

## pool() [3/5]

mongocxx::v1::pool::pool | ( | v1::uri const & | uri,
|  | options | opts )

Initialize this pool with the given URI.

Note
  No connection is attempted until a client object is acquired from this pool.

Exceptions

  mongocxx::v1::exception | if a client-side error is encountered.

## pool() [4/5]

mongocxx::v1::pool::pool | ( | v1::uri const & | uri | ) |

Initialize this pool with the given URI.

Note
  No connection is attempted until a client object is acquired from this pool.

Exceptions

  mongocxx::v1::exception | if a client-side error is encountered.

## pool() [5/5]

mongocxx::v1::pool::pool | ( |  | ) |

explicit

Initialize this pool with default URI options.

Important
  No connection to the MongoDB server(s) is attempted until the first client object is acquired.

Exceptions

  mongocxx::v1::exception | if a client-side error is encountered.

## Member Function Documentation

## acquire()

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

Return a client object associated with this pool.

This function blocks the current thread until a client object is available or "waitQueueTimeoutMS" is triggered.

Note
  Connection to the MongoDB server(s) is attempted in a background "monitoring" thread when the first client object is acquired. Server-side errors will only be encountered during or after the first command is executed.

Returns
  A handle to a client object connected to the MongoDB server(s).

Exceptions

  mongocxx::v1::exception | with mongocxx::v1::pool::errc::wait_queue_timeout if a client object could not be acquired within "waitQueueTimeoutMS".

## error_category()

std::error_category const & mongocxx::v1::pool::error_category | ( |  | ) |

static

The error category for mongocxx::v1::pool::errc.

## operator bool()

mongocxx::v1::pool::operator bool | ( |  | ) | const

explicit

Return true when *this is NOT in an assign-or-destroy-only state.

## operator=() [1/2]

pool & mongocxx::v1::pool::operator= | ( | pool && | other | ) |

noexcept

Move assignment.

Postconditions:
  - other is in an assign-or-destroy-only state.

## operator=() [2/2]

pool & mongocxx::v1::pool::operator= | ( | pool const & | other | ) |

delete

This class is not copyable.

## try_acquire()

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

Return a client object associated with this pool.

Note
  The first client object acquired from a pool blocks the current thread until the initial connection to the MongoDB server(s) is established.
  Connection to the MongoDB server(s) is attempted in a background "monitoring" thread when the first client object is acquired. Server-side errors will only be encountered during or after the first command is executed.

Returns
  Empty when a client object is not immediately available.

## Friends And Related Symbol Documentation

## make_error_code

std::error_code make_error_code | ( | errc | v | ) |

friend

Support implicit conversion to std::error_code.

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

- mongocxx/v1/pool.hpp