MongoDB C++ Driver 4.4.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
49class pool {
50 private:
51 class impl;
52 void* _impl;
53
54 public:
55 class options;
56 class entry;
57
64
71 MONGOCXX_ABI_EXPORT_CDECL() pool(pool&& other) noexcept;
72
79 MONGOCXX_ABI_EXPORT_CDECL(pool&) operator=(pool&& other) noexcept;
80
84 pool(pool const& other) = delete;
85
89 pool& operator=(pool const& other) = delete;
90
100
101 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() pool(v1::uri const& uri);
104
113
117 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
118
134
147
151 enum class errc {
154 };
155
159 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
160
164 friend std::error_code make_error_code(errc v) {
165 return {static_cast<int>(v), error_category()};
166 }
167
168 class internal;
169
170 private:
171 /* explicit(false) */ pool(void* impl);
172};
173
178 private:
179 class impl;
180 void* _impl;
181
182 public:
187
195
202 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
203
208
212 MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
213
217 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() options(v1::client::options opts);
218
226
231
232 class internal;
233};
234
238class pool::entry {
239 private:
240 class impl;
241 void* _impl;
242
243 public:
248
256
263 MONGOCXX_ABI_EXPORT_CDECL(entry&) operator=(entry&& other) noexcept;
264
268 entry(entry const& other) = delete;
269
273 entry& operator=(entry const& other) = delete;
274
279
284
291 MONGOCXX_ABI_EXPORT_CDECL(entry&) operator=(std::nullptr_t);
292
296 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
297
303 MONGOCXX_ABI_EXPORT_CDECL(v1::database) operator[](bsoncxx::v1::stdx::string_view name);
306
307 class internal;
308
309 private:
310 /* explicit(false) */ entry(void* impl);
311};
312
313} // namespace v1
314} // namespace mongocxx
315
316namespace std {
317
318template <>
319struct is_error_code_enum<mongocxx::v1::pool::errc> : true_type {};
320
321} // namespace std
322
324
A connection to a MongoDB deployment.
Definition client.hpp:60
A handle to a client object owned by an associated pool.
Definition pool.hpp:238
~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:177
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:164
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:151
@ wait_queue_timeout
Failed to acquire a client object due to "waitQueueTimeoutMS".
Definition pool.hpp:153
@ zero
Zero.
Definition pool.hpp:152
A MongoDB connection string.
Definition uri.hpp:89
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.