Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to asynchronously wait for a duration of time #12

Closed
lewissbaker opened this issue May 27, 2017 · 3 comments
Closed

Add ability to asynchronously wait for a duration of time #12

lewissbaker opened this issue May 27, 2017 · 3 comments
Assignees

Comments

@lewissbaker
Copy link
Owner

lewissbaker commented May 27, 2017

Add the ability to do something like:

cppcoro::task<> do_something(cppcoro::io_context ioCtx)
{
  using namespace std::chrono_literals;
  co_await ioCtx.schedule_after(30s);
}
@lewissbaker lewissbaker self-assigned this Jun 27, 2017
@lewissbaker
Copy link
Owner Author

I'm working on support for this at the moment for the io_service class.

I'm also adding the ability to cancel a timer using a cancellation_token.

using namespace std::chrono_literals;
cppcoro::task<> do_something(cppcoro::io_service& io, cancellation_token ct)
{
  // throws cppcoro::operation_cancelled if cancellation is requested before timer elapses.
  co_await io.schedule_after(30s, ct); 
}

@lewissbaker
Copy link
Owner Author

830c4d1 has implemented this for io_service on the Windows platform.

I've also added support for cancellation of timers by passing an optional cancellation_token into the schedule_after method.

I'm still working on adding some documentation for io_service and schedule_after() to the README.

@lewissbaker
Copy link
Owner Author

I've now added some basic docs to the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant