doc/html/boost_asio/example/cpp11/type_erasure/sleep.cpp – 1.86.0

doc/html/boost_asio/example/cpp11/type_erasure/sleep.cpp

//
// sleep.cpp
// ~~~~~~~~~
//
// Copyright (c) 2003-2024 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)
//

#include "sleep.hpp"
#include <boost/asio/consign.hpp>
#include <boost/asio/steady_timer.hpp>
#include 

void async_sleep_impl(
    boost::asio::any_completion_handler handler,
    boost::asio::any_io_executor ex, std::chrono::nanoseconds duration)
{
  auto timer = std::make_shared<:asio::steady_timer>(ex, duration);
  timer->async_wait(boost::asio::consign(std::move(handler), timer));
}

Read more here: Source link