neorados::RADOS::make_with_librados(*rados))),
m_cct(m_rados_api->cct()),
m_io_context(m_rados_api->get_io_context()),
- m_api_strand(m_io_context),
+ m_api_strand(std::make_unique<boost::asio::io_context::strand>(
+ m_io_context)),
m_context_wq(std::make_unique<asio::ContextWQ>(m_cct, m_io_context)) {
ldout(m_cct, 20) << dendl;
AsioEngine::~AsioEngine() {
ldout(m_cct, 20) << dendl;
+ m_api_strand.reset();
}
void AsioEngine::dispatch(Context* ctx, int r) {
inline boost::asio::io_context::strand& get_api_strand() {
// API client callbacks should never fire concurrently
- return m_api_strand;
+ return *m_api_strand;
}
inline asio::ContextWQ* get_work_queue() {
CephContext* m_cct;
boost::asio::io_context& m_io_context;
- boost::asio::io_context::strand m_api_strand;
+ std::unique_ptr<boost::asio::io_context::strand> m_api_strand;
std::unique_ptr<asio::ContextWQ> m_context_wq;
};
namespace asio {
ContextWQ::ContextWQ(CephContext* cct, boost::asio::io_context& io_context)
- : m_cct(cct), m_io_context(io_context), m_strand(io_context),
+ : m_cct(cct), m_io_context(io_context),
+ m_strand(std::make_unique<boost::asio::io_context::strand>(io_context)),
m_queued_ops(0) {
ldout(m_cct, 20) << dendl;
}
ContextWQ::~ContextWQ() {
ldout(m_cct, 20) << dendl;
drain();
+ m_strand.reset();
}
void ContextWQ::drain() {
// new items might be queued while we are trying to drain, so we
// might need to post the handler multiple times
- boost::asio::post(m_strand, [this, ctx]() { drain_handler(ctx); });
+ boost::asio::post(*m_strand, [this, ctx]() { drain_handler(ctx); });
}
} // namespace asio
#include "include/common_fwd.h"
#include "include/Context.h"
#include <atomic>
+#include <memory>
#include <boost/asio/io_context.hpp>
#include <boost/asio/io_context_strand.hpp>
#include <boost/asio/post.hpp>
// ensure all legacy ContextWQ users are dispatched sequentially for
// backwards compatibility (i.e. might not be concurrent thread-safe)
- boost::asio::post(m_strand, [this, ctx, r]() {
+ boost::asio::post(*m_strand, [this, ctx, r]() {
ctx->complete(r);
ceph_assert(m_queued_ops > 0);
private:
CephContext* m_cct;
boost::asio::io_context& m_io_context;
- boost::asio::io_context::strand m_strand;
+ std::unique_ptr<boost::asio::io_context::strand> m_strand;
std::atomic<uint64_t> m_queued_ops;