// detail/impl/kqueue_reactor.ipp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2005 Stefan Arentz (stefan at soze dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
scheduler_.post_deferred_completions(ops);
}
+void kqueue_reactor::cancel_ops_by_key(socket_type,
+ kqueue_reactor::per_descriptor_data& descriptor_data,
+ int op_type, void* cancellation_key)
+{
+ if (!descriptor_data)
+ return;
+
+ mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
+
+ op_queue<operation> ops;
+ op_queue<reactor_op> other_ops;
+ while (reactor_op* op = descriptor_data->op_queue_[op_type].front())
+ {
+ descriptor_data->op_queue_[op_type].pop();
+ if (op->cancellation_key_ == cancellation_key)
+ {
+ op->ec_ = boost::asio::error::operation_aborted;
+ ops.push(op);
+ }
+ else
+ other_ops.push(op);
+ }
+ descriptor_data->op_queue_[op_type].push(other_ops);
+
+ descriptor_lock.unlock();
+
+ scheduler_.post_deferred_completions(ops);
+}
+
void kqueue_reactor::deregister_descriptor(socket_type descriptor,
kqueue_reactor::per_descriptor_data& descriptor_data, bool closing)
{