-
Notifications
You must be signed in to change notification settings - Fork 477
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
Deprecate and remove 'eager' task classes task
and shared_task
#29
Comments
Started the process of removing use of There are still the |
Commit 722fe1b removes use of eager tasks from Only |
Commit 421de76 removes last of eager task usage from tests (except where testing eager tasks themselves). |
Commit 64b0a04 removes the All that remains now is renaming |
Commit bf9eb2c has implemented the rename. Closing. |
…pveyor Remove cake, appveyor and unmaintained scripts
Once we have a way to synchronously block waiting for a task in #27 and
when_all
in #10 there shouldn't be any need for the eagerly started task types any more and we can limit use to just the lazy task types (ie.lazy_task
andshared_lazy_task
)One of the big motivations for getting rid of eagerly-started tasks is that it is difficult to write exception-safe code with use of eagerly-started tasks that aren't immediately
co_await
ed.We don't want to leave dangling tasks/computation as this can lead to ignored/uncaught exceptions or unsynchronised access to shared resources.
For example, consider the case where we want to execute two tasks concurrently and wait for them both to finish before continuing, using their results:
To implement this in an exception-safe way we'd need to modify the function as follows:
Compared with
lazy_task
version which is both concise and exception-safe:With a
lazy_task
, the task is either beingco_await
ed by some other coroutine or it is not executing (it has either not yet started, or has completed executing) and so thelazy_task
is always safe to destruct and will free the coroutine frame it owns.A side-benefit of using
lazy_task
everywhere is that it can be implemented without the need forstd::atomic
operations to synchronise coroutine completion and awaiter. This can have some potential benefits for performance by avoiding use of atomic operations for basic sequential flow of execution.The text was updated successfully, but these errors were encountered: