24#include <seastar/util/modules.hh>
27#include <boost/intrusive/list.hpp>
28#include <boost/intrusive/slist.hpp>
31namespace bi = boost::intrusive;
50class cancellable_queue {
53 friend class cancellable_queue;
56 cancellable_queue* _ref;
57 bi::slist_member_hook<> _hook;
61 link() noexcept : _ref(
nullptr) {}
62 ~link() { assert(_ref ==
nullptr); }
64 void enqueue(cancellable_queue& cq)
noexcept {
68 void maybe_dequeue() noexcept {
69 if (_ref !=
nullptr) {
76 static_assert(
sizeof(link) ==
sizeof(
void*),
"cancellable_queue::link size is too big");
77 using list_of_links_t = bi::slist<link,
78 bi::constant_time_size<false>,
80 bi::member_hook<link, bi::slist_member_hook<>, &link::_hook>>;
83 list_of_links_t _rest;
85 void push_back(link& il)
noexcept;
86 void pop_front() noexcept;
89 cancellable_queue() noexcept : _first(
nullptr) {}
90 cancellable_queue(
const cancellable_queue&) =
delete;
91 cancellable_queue(cancellable_queue&& o)
noexcept;
92 cancellable_queue& operator=(cancellable_queue&& o)
noexcept;
103class intent_reference :
public bi::list_base_hook<bi::link_mode<bi::auto_unlink>> {
105 using container_type = bi::list<intent_reference, bi::constant_time_size<false>>;
106 static constexpr uintptr_t _cancelled_intent = 1;
109 void on_cancel() noexcept { _intent =
reinterpret_cast<io_intent*
>(_cancelled_intent); }
110 bool is_cancelled() const noexcept {
return _intent ==
reinterpret_cast<io_intent*
>(_cancelled_intent); }
113 intent_reference(io_intent* intent)
noexcept;
115 intent_reference(intent_reference&& o) noexcept : _intent(std::exchange(o._intent,
nullptr)) {
116 container_type::node_algorithms::swap_nodes(o.this_ptr(), this_ptr());
119 intent_reference& operator=(intent_reference&& o)
noexcept {
121 _intent = std::exchange(o._intent,
nullptr);
123 container_type::node_algorithms::swap_nodes(o.this_ptr(), this_ptr());
128 io_intent* retrieve()
const;
Definition: io_intent.hh:44
Seastar API namespace.
Definition: abort_on_ebadf.hh:26