Loading...
Searching...
No Matches
pool.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/v1/pool-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <mongocxx/v1/database-fwd.hpp>
#include <mongocxx/v1/uri-fwd.hpp>
#include <bsoncxx/v1/stdx/optional.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <mongocxx/v1/client.hpp> // IWYU pragma: export
#include <mongocxx/v1/config/export.hpp>
#include <cstddef>
#include <system_error>
#include <type_traits>
namespace mongocxx {
namespace v1 {
class pool {
private:
class impl;
void* _impl;
public:
class options;
class entry;
MONGOCXX_ABI_EXPORT_CDECL() ~pool();
MONGOCXX_ABI_EXPORT_CDECL() pool(pool&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(pool&) operator=(pool&& other) noexcept;
pool(pool const& other) = delete;
pool& operator=(pool const& other) = delete;
MONGOCXX_ABI_EXPORT_CDECL() pool(v1::uri const& uri, options opts);
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() pool(v1::uri const& uri);
explicit MONGOCXX_ABI_EXPORT_CDECL() pool();
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(entry) acquire();
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<entry>) try_acquire();
enum class errc {
zero,
wait_queue_timeout,
};
static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
friend std::error_code make_error_code(errc v) {
return {static_cast<int>(v), error_category()};
}
class internal;
private:
/* explicit(false) */ pool(void* impl);
};
class pool::options {
private:
class impl;
void* _impl;
public:
MONGOCXX_ABI_EXPORT_CDECL() ~options();
MONGOCXX_ABI_EXPORT_CDECL() options(options&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() options(options const& other);
MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() options(v1::client::options opts);
MONGOCXX_ABI_EXPORT_CDECL() options();
MONGOCXX_ABI_EXPORT_CDECL(v1::client::options) client_opts() const;
class internal;
};
class pool::entry {
private:
class impl;
void* _impl;
public:
MONGOCXX_ABI_EXPORT_CDECL() ~entry();
MONGOCXX_ABI_EXPORT_CDECL() entry(entry&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(entry&) operator=(entry&& other) noexcept;
entry(entry const& other) = delete;
entry& operator=(entry const& other) = delete;
MONGOCXX_ABI_EXPORT_CDECL(v1::client*) operator->();
MONGOCXX_ABI_EXPORT_CDECL(v1::client&) operator*();
MONGOCXX_ABI_EXPORT_CDECL(entry&) operator=(std::nullptr_t);
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::database) database(bsoncxx::v1::stdx::string_view name);
MONGOCXX_ABI_EXPORT_CDECL(v1::database) operator[](bsoncxx::v1::stdx::string_view name);
class internal;
private:
/* explicit(false) */ entry(void* impl);
};
} // namespace v1
} // namespace mongocxx
namespace std {
template <>
struct is_error_code_enum<mongocxx::v1::pool::errc> : true_type {};
} // namespace std
#include <mongocxx/v1/detail/postlude.hpp>
mongocxx::v1::client
A connection to a MongoDB deployment.
Definition client.hpp:60
mongocxx::v1::pool::entry
A handle to a client object owned by an associated pool.
Definition pool.hpp:238
mongocxx::v1::pool::entry::~entry
~entry()
Destroy this object, releasing the managed client object back to the associated pool.
mongocxx::v1::pool::entry::database
v1::database database(bsoncxx::v1::stdx::string_view name)
Equivalent to (*this)->database(name).
mongocxx::v1::pool::entry::entry
entry(entry &&other) noexcept
Move constructor.
mongocxx::v1::pool::options
Options for mongocxx::v1::pool.
Definition pool.hpp:177
mongocxx::v1::pool::options::client_opts
v1::client::options client_opts() const
Return the current client options.
mongocxx::v1::pool::options::~options
~options()
Destroy this object.
mongocxx::v1::pool::options::options
options(options &&other) noexcept
Move constructor.
mongocxx::v1::pool::acquire
entry acquire()
Return a client object associated with this pool.
mongocxx::v1::pool::error_category
static std::error_category const & error_category()
The error category for mongocxx::v1::pool::errc.
mongocxx::v1::pool::~pool
~pool()
Destroy this object.
mongocxx::v1::pool::pool
pool(pool &&other) noexcept
Move constructor.
mongocxx::v1::pool::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition pool.hpp:164
mongocxx::v1::pool::pool
pool()
Initialize this pool with default URI options.
mongocxx::v1::pool::try_acquire
bsoncxx::v1::stdx::optional< entry > try_acquire()
Return a client object associated with this pool.
mongocxx::v1::pool::errc
errc
Errors codes which may be returned by mongocxx::v1::pool.
Definition pool.hpp:151
mongocxx::v1::pool::errc::wait_queue_timeout
@ wait_queue_timeout
Failed to acquire a client object due to "waitQueueTimeoutMS".
Definition pool.hpp:153
mongocxx::v1::pool::errc::zero
@ zero
Zero.
Definition pool.hpp:152
mongocxx::v1::uri
A MongoDB connection string.
Definition uri.hpp:89
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
client.hpp
Provides mongocxx::v1::client.
database-fwd.hpp
Declares mongocxx::v1::database.
pool-fwd.hpp
Declares mongocxx::v1::pool.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
uri-fwd.hpp
Declares mongocxx::v1::uri.