// detail/impl/strand_executor_service.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)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
return !!call_stack<strand_impl>::contains(impl.get());
}
+bool strand_executor_service::push_waiting_to_ready(implementation_type& impl)
+{
+ impl->mutex_->lock();
+ impl->ready_queue_.push(impl->waiting_queue_);
+ bool more_handlers = impl->locked_ = !impl->ready_queue_.empty();
+ impl->mutex_->unlock();
+ return more_handlers;
+}
+
+void strand_executor_service::run_ready_handlers(implementation_type& impl)
+{
+ // Indicate that this strand is executing on the current thread.
+ call_stack<strand_impl>::context ctx(impl.get());
+
+ // Run all ready handlers. No lock is required since the ready queue is
+ // accessed only within the strand.
+ boost::system::error_code ec;
+ while (scheduler_operation* o = impl->ready_queue_.front())
+ {
+ impl->ready_queue_.pop();
+ o->complete(impl.get(), ec, 0);
+ }
+}
+
} // namespace detail
} // namespace asio
} // namespace boost