#include "librbd/asio/ContextWQ.h"
#include "include/Context.h"
#include "common/Cond.h"
-#include <boost/asio/bind_executor.hpp>
-#include <boost/asio/post.hpp>
namespace librbd {
namespace asio {
// 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_io_context, boost::asio::bind_executor(
- m_strand, [this, ctx]() { drain_handler(ctx); }));
-}
-
-void ContextWQ::queue(Context *ctx, int r) {
- ++m_queued_ops;
-
- // ensure all legacy ContextWQ users are dispatched sequentially for backwards
- // compatibility (i.e. might not be concurrent thread-safe)
- boost::asio::post(m_io_context, boost::asio::bind_executor(
- m_strand,
- [this, ctx, r]() {
- ctx->complete(r);
-
- ceph_assert(m_queued_ops > 0);
- --m_queued_ops;
- }));
+ boost::asio::post(m_strand, [this, ctx]() { drain_handler(ctx); });
}
} // namespace asio
#ifndef CEPH_LIBRBD_ASIO_CONTEXT_WQ_H
#define CEPH_LIBRBD_ASIO_CONTEXT_WQ_H
+#include "include/Context.h"
#include <atomic>
#include <boost/asio/io_context.hpp>
#include <boost/asio/io_context_strand.hpp>
-
-struct Context;
+#include <boost/asio/post.hpp>
namespace librbd {
namespace asio {
explicit ContextWQ(boost::asio::io_context& io_context);
void drain();
- void queue(Context *ctx, int r = 0);
+
+ void queue(Context *ctx, int r = 0) {
+ ++m_queued_ops;
+
+ // 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]() {
+ ctx->complete(r);
+
+ ceph_assert(m_queued_ops > 0);
+ --m_queued_ops;
+ });
+ }
private:
boost::asio::io_context& m_io_context;