24#include <seastar/util/assert.hh>
25#include <seastar/util/modules.hh>
28#include <boost/intrusive/list.hpp>
29#include <boost/intrusive/slist.hpp>
32namespace bi = boost::intrusive;
51class cancellable_queue {
54 friend class cancellable_queue;
57 cancellable_queue* _ref;
58 bi::slist_member_hook<> _hook;
62 link() noexcept : _ref(
nullptr) {}
63 ~link() { SEASTAR_ASSERT(_ref ==
nullptr); }
65 void enqueue(cancellable_queue& cq)
noexcept {
69 void maybe_dequeue() noexcept {
70 if (_ref !=
nullptr) {
77 static_assert(
sizeof(link) ==
sizeof(
void*),
"cancellable_queue::link size is too big");
78 using list_of_links_t = bi::slist<link,
79 bi::constant_time_size<false>,
81 bi::member_hook<link, bi::slist_member_hook<>, &link::_hook>>;
84 list_of_links_t _rest;
86 void push_back(link& il)
noexcept;
87 void pop_front() noexcept;
90 cancellable_queue() noexcept : _first(
nullptr) {}
91 cancellable_queue(
const cancellable_queue&) =
delete;
92 cancellable_queue(cancellable_queue&& o)
noexcept;
93 cancellable_queue& operator=(cancellable_queue&& o)
noexcept;
104class intent_reference :
public bi::list_base_hook<bi::link_mode<bi::auto_unlink>> {
106 using container_type = bi::list<intent_reference, bi::constant_time_size<false>>;
107 static constexpr uintptr_t _cancelled_intent = 1;
110 void on_cancel() noexcept { _intent =
reinterpret_cast<io_intent*
>(_cancelled_intent); }
111 bool is_cancelled() const noexcept {
return _intent ==
reinterpret_cast<io_intent*
>(_cancelled_intent); }
114 intent_reference(io_intent* intent)
noexcept;
116 intent_reference(intent_reference&& o) noexcept : _intent(std::exchange(o._intent,
nullptr)) {
117 container_type::node_algorithms::swap_nodes(o.this_ptr(), this_ptr());
120 intent_reference& operator=(intent_reference&& o)
noexcept {
122 _intent = std::exchange(o._intent,
nullptr);
124 container_type::node_algorithms::swap_nodes(o.this_ptr(), this_ptr());
129 io_intent* retrieve()
const;
Definition: io_intent.hh:44
Seastar API namespace.
Definition: abort_on_ebadf.hh:26