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 classes for Task and SharedTask in threadpool #5391

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

ypatia
Copy link
Member

@ypatia ypatia commented Nov 29, 2024

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

@ypatia ypatia force-pushed the yt/sc-59606/threadpool_with_tasks branch from 411e836 to e3aff67 Compare November 29, 2024 13:57
@ypatia ypatia force-pushed the yt/sc-59606/threadpool_with_tasks branch from 0b11b03 to 2d0a155 Compare November 29, 2024 14:10
@ypatia ypatia force-pushed the yt/sc-59606/threadpool_with_tasks branch from df3d995 to 77b52a2 Compare November 29, 2024 15:00
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

Successfully merging this pull request may close these issues.

1 participant