2
0
mirror of https://github.com/boostorg/cobalt.git synced 2026-01-19 04:02:16 +00:00

fixed main tests.

This commit is contained in:
Klemens Morgenstern
2023-10-18 11:29:07 +08:00
parent a7c2aec7fc
commit ae83cdd7fb
2 changed files with 14 additions and 20 deletions

View File

@@ -1,20 +1,17 @@
// Copyright (c) 2023 Klemens D. Morgenstern
// Copyright (c) 2022 Klemens D. Morgenstern
//
// 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 <boost/cobalt.hpp>
#include <boost/cobalt/main.hpp>
#include <boost/cobalt/op.hpp>
#include <boost/asio/steady_timer.hpp>
using namespace boost;
// tag::timer_example[]
cobalt::main co_main(int argc, char * argv[]) // <1>
boost::cobalt::main co_main(int argc, char *argv[])
{
asio::steady_timer tim{co_await asio::this_coro::executor, // <2>
std::chrono::milliseconds(std::stoi(argv[1]))}; // <3>
co_await tim.async_wait(cobalt::use_op); // <4>
co_return 0; // <5>
boost::asio::steady_timer tim{co_await boost::asio::this_coro::executor, std::chrono::milliseconds(50)};
co_await tim.async_wait(boost::cobalt::use_op);
co_return 0;
}
// end::timer_example[]

View File

@@ -1,20 +1,17 @@
// Copyright (c) 2023 Klemens D. Morgenstern
// Copyright (c) 2022 Klemens D. Morgenstern
//
// 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 <boost/cobalt.hpp>
#include <boost/cobalt/main.hpp>
#include <boost/cobalt/op.hpp>
#include <boost/asio/steady_timer.hpp>
using namespace boost;
// tag::timer_example[]
cobalt::main co_main(int argc, char * argv[]) // <1>
boost::cobalt::main co_main(int argc, char *argv[])
{
asio::steady_timer tim{co_await asio::this_coro::executor, // <2>
std::chrono::milliseconds(std::stoi(argv[1]))}; // <3>
co_await tim.async_wait(cobalt::use_op); // <4>
co_return 0; // <5>
boost::asio::steady_timer tim{co_await boost::asio::this_coro::executor, std::chrono::milliseconds(50)};
co_await tim.async_wait(boost::cobalt::use_op);
co_return 0;
}
// end::timer_example[]