forked from ceph/seastar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: stop wrapping tasks with unique_ptr
Since the very beginning, we wrapped tasks and continuations with unique_ptr for exception safety. It wasn't safe, however - once a task is created, it must be executed and cannot be just destroyed and freed, since anything that depends on the task will not be run. This became even more pronounced with 4d811de ("task: resumable tasks"), as tasks are now responsible for their own reclamation (the "dispose" part of task::run_and_dispose()). To make it clear that one cannot rely on unique_ptr<task> being safe, replace unique_ptr<task> with a plain task* (and make_unique with naked new calls). To mark the fact that the functions in which this happens are not exeception safe, annotate them as noexcept. Some notes: - std::move()ing a pointer will not clear it, so some call sites have changed to use std::exchange() - repeat(), do_until(), and the like were using unique_ptr(this) to destroy the task in run_and_dispose() unless moved from. This was changed to plain "delete this". Tests: unit(dev, debug) Message-Id: <[email protected]>
- Loading branch information
Showing
7 changed files
with
93 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.