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

Support std::future<void> with thread_pool::enqueue #37

Closed
DeveloperPaul123 opened this issue Jun 1, 2023 · 0 comments · Fixed by #38
Closed

Support std::future<void> with thread_pool::enqueue #37

DeveloperPaul123 opened this issue Jun 1, 2023 · 0 comments · Fixed by #38
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@DeveloperPaul123
Copy link
Owner

Currently it's not possible to do the following:

dp::thread_pool pool;
auto value = 8;
auto future = pool.enqueue([](int& x) { x *= 2; }, std::ref(value));
future.wait();

dp::thread_pool should support this use case.

With the upcoming std::future updates and extensions (i.e. std::when_all, std::when_any) we may not need #27. Though, having something built in to the class would save on memory usage since users would presumably have to store std::future<void> in a list of some sort (i.e. std::vector<>).

@DeveloperPaul123 DeveloperPaul123 added the enhancement New feature or request label Jun 1, 2023
@DeveloperPaul123 DeveloperPaul123 self-assigned this Jun 1, 2023
@DeveloperPaul123 DeveloperPaul123 added this to the 0.6.0 milestone Jun 1, 2023
DeveloperPaul123 added a commit that referenced this issue Jun 1, 2023
Added support for `std::future<void>` return type with `dp::thread_pool::enqueue`.

Fixes #37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant