]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/AsioEngine.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_ASIO_ENGINE_H
5 #define CEPH_LIBRBD_ASIO_ENGINE_H
7 #include "include/common_fwd.h"
8 #include "include/rados/librados_fwd.hpp"
10 #include <boost/asio/dispatch.hpp>
11 #include <boost/asio/io_context.hpp>
12 #include <boost/asio/io_context_strand.hpp>
13 #include <boost/asio/post.hpp>
16 namespace neorados
{ struct RADOS
; }
20 namespace asio
{ struct ContextWQ
; }
24 explicit AsioEngine(std::shared_ptr
<librados::Rados
> rados
);
25 explicit AsioEngine(librados::IoCtx
& io_ctx
);
28 AsioEngine(AsioEngine
&&) = delete;
29 AsioEngine(const AsioEngine
&) = delete;
30 AsioEngine
& operator=(const AsioEngine
&) = delete;
32 inline neorados::RADOS
& get_rados_api() {
36 inline boost::asio::io_context
& get_io_context() {
39 inline operator boost::asio::io_context
&() {
43 using executor_type
= boost::asio::io_context::executor_type
;
44 inline executor_type
get_executor() {
45 return m_io_context
.get_executor();
48 inline boost::asio::io_context::strand
& get_api_strand() {
49 // API client callbacks should never fire concurrently
53 inline asio::ContextWQ
* get_work_queue() {
54 return m_context_wq
.get();
58 void dispatch(T
&& t
) {
59 boost::asio::dispatch(m_io_context
, std::forward
<T
>(t
));
61 void dispatch(Context
* ctx
, int r
);
65 boost::asio::post(m_io_context
, std::forward
<T
>(t
));
67 void post(Context
* ctx
, int r
);
70 std::shared_ptr
<neorados::RADOS
> m_rados_api
;
73 boost::asio::io_context
& m_io_context
;
74 std::unique_ptr
<boost::asio::io_context::strand
> m_api_strand
;
75 std::unique_ptr
<asio::ContextWQ
> m_context_wq
;
80 #endif // CEPH_LIBRBD_ASIO_ENGINE_H