-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add classes for Task and SharedTask in threadpool (#5391)
Currently `ThreadPool::Task` is a typedef to `std:: future<Status>`. This PR: 1) Replaces this with a full class that imposes things like `wait` for our async processes to go through our ThreadPool's wait method. In that way, we never use a `std::future`'s `wait` method directly and we avoid possible deadlocks because only the ThreadPool's `wait` will yield. 2) Adjusts the structure and relationship of tasks and the threadpool so that the caller can rely on the task's internal functions and doesn't need to keep track of the relationship between the ThreadPool and each task manually throughout the codebase. 3) Adds a new first class citizen of our ThreadPool: `SharedTask`, that is encapsulating `std::shared_future` which allows multiple threads to wait on an async operation result to become available. This is needed for the upcoming work on parallelizing IO and compute operations in the codebase even further. This is heavily influenced from similar work by @Shelnutt2. --- TYPE: IMPROVEMENT DESC: Add classes for Task and SharedTask in threadpool --------- Co-authored-by: Seth Shelnutt <[email protected]>
- Loading branch information
Showing
6 changed files
with
244 additions
and
32 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.