/// The type of the executor associated with the object.
typedef Executor executor_type;
+ /// Rebinds the handle type to another executor.
+ template <typename Executor1>
+ struct rebind_executor
+ {
+ /// The handle type when rebound to the specified executor.
+ typedef basic_object_handle<Executor1> other;
+ };
+
/// The native representation of a handle.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined native_handle_type;
* immediate completion, invocation of the handler will be performed in a
* manner equivalent to using boost::asio::post().
*/
- template <typename WaitHandler>
- BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ template <
+ BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code))
+ WaitHandler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
+ BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(WaitHandler,
void (boost::system::error_code))
- async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
+ async_wait(
+ BOOST_ASIO_MOVE_ARG(WaitHandler) handler
+ BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
{
- boost::asio::async_completion<WaitHandler,
- void (boost::system::error_code)> init(handler);
-
- impl_.get_service().async_wait(impl_.get_implementation(),
- init.completion_handler, impl_.get_implementation_executor());
-
- return init.result.get();
+ return async_initiate<WaitHandler, void (boost::system::error_code)>(
+ initiate_async_wait(this), handler);
}
private:
basic_object_handle(const basic_object_handle&) BOOST_ASIO_DELETED;
basic_object_handle& operator=(const basic_object_handle&) BOOST_ASIO_DELETED;
+ class initiate_async_wait
+ {
+ public:
+ typedef Executor executor_type;
+
+ explicit initiate_async_wait(basic_object_handle* self)
+ : self_(self)
+ {
+ }
+
+ executor_type get_executor() const BOOST_ASIO_NOEXCEPT
+ {
+ return self_->get_executor();
+ }
+
+ template <typename WaitHandler>
+ void operator()(BOOST_ASIO_MOVE_ARG(WaitHandler) handler) const
+ {
+ // If you get an error on the following line it means that your handler
+ // does not meet the documented type requirements for a WaitHandler.
+ BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
+
+ detail::non_const_lvalue<WaitHandler> handler2(handler);
+ self_->impl_.get_service().async_wait(
+ self_->impl_.get_implementation(), handler2.value,
+ self_->impl_.get_implementation_executor());
+ }
+
+ private:
+ basic_object_handle* self_;
+ };
+
boost::asio::detail::io_object_impl<
boost::asio::detail::win_object_handle_service, Executor> impl_;
};