MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
pool.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/v1/pool-fwd.hpp> // IWYU pragma: export
18
19//
20
22
25
28
29#include <mongocxx/v1/client.hpp> // IWYU pragma: export
31
32#include <cstddef>
33#include <system_error>
34#include <type_traits>
35
36namespace mongocxx {
37namespace v1 {
38
51class pool {
52 private:
53 class impl;
54 void* _impl;
55
56 public:
57 class options;
58 class entry;
59
66
73 MONGOCXX_ABI_EXPORT_CDECL() pool(pool&& other) noexcept;
74
81 MONGOCXX_ABI_EXPORT_CDECL(pool&) operator=(pool&& other) noexcept;
82
86 pool(pool const& other) = delete;
87
91 pool& operator=(pool const& other) = delete;
92
102
103 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() pool(v1::uri const& uri);
106
115
119 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
120
136
149
155 enum class errc {
158 };
159
165 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
166
172 friend std::error_code make_error_code(errc v) {
173 return {static_cast<int>(v), error_category()};
174 }
175
176 class internal;
177
178 private:
179 /* explicit(false) */ pool(void* impl);
180};
181
188 private:
189 class impl;
190 void* _impl;
191
192 public:
197
205
212 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
213
218
222 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
223
227 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() options(v1::client::options opts);
228
236
241
242 class internal;
243};
244
250class pool::entry {
251 private:
252 class impl;
253 void* _impl;
254
255 public:
260
268
275 MONGOCXX_ABI_EXPORT_CDECL(entry&) operator=(entry&& other) noexcept;
276
280 entry(entry const& other) = delete;
281
285 entry& operator=(entry const& other) = delete;
286
291
296
303 MONGOCXX_ABI_EXPORT_CDECL(entry&) operator=(std::nullptr_t);
304
308 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
309
315 MONGOCXX_ABI_EXPORT_CDECL(v1::database) operator[](bsoncxx::v1::stdx::string_view name);
318
319 class internal;
320
321 private:
322 /* explicit(false) */ entry(void* impl);
323};
324
325} // namespace v1
326} // namespace mongocxx
327
328namespace std {
329
330template <>
331struct is_error_code_enum<mongocxx::v1::pool::errc> : true_type {};
332
333} // namespace std
334
336
A connection to a MongoDB deployment.
Definition client.hpp:60
A handle to a client object owned by an associated pool.
Definition pool.hpp:250
~entry()
Destroy this object, releasing the managed client object back to the associated pool.
v1::database database(bsoncxx::v1::stdx::string_view name)
Equivalent to (*this)->database(name).
entry(entry &&other) noexcept
Move constructor.
Options for mongocxx::v1::pool.
Definition pool.hpp:187
v1::client::options client_opts() const
Return the current client options.
~options()
Destroy this object.
options(options &&other) noexcept
Move constructor.
entry acquire()
Return a client object associated with this pool.
static std::error_category const & error_category()
The error category for mongocxx::v1::pool::errc.
~pool()
Destroy this object.
pool(pool &&other) noexcept
Move constructor.
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition pool.hpp:172
pool()
Initialize this pool with default URI options.
bsoncxx::v1::stdx::optional< entry > try_acquire()
Return a client object associated with this pool.
errc
Errors codes which may be returned by mongocxx::v1::pool.
Definition pool.hpp:155
@ wait_queue_timeout
Failed to acquire a client object due to "waitQueueTimeoutMS".
Definition pool.hpp:157
@ zero
Zero.
Definition pool.hpp:156
A MongoDB connection string.
Definition uri.hpp:96
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v1::client.
Declares mongocxx::v1::database.
Declares mongocxx::v1::pool.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Declares mongocxx::v1::uri.