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

[FEATURE] Add bulk enqueue functions #20

Open
DeveloperPaul123 opened this issue Oct 17, 2022 · 2 comments
Open

[FEATURE] Add bulk enqueue functions #20

DeveloperPaul123 opened this issue Oct 17, 2022 · 2 comments
Assignees

Comments

@DeveloperPaul123
Copy link
Owner

Description

Would be good to add versions of enqueue() and enqueue_detach() that would allow for submission of multiple tasks at once so that they can be batched.

@DeveloperPaul123 DeveloperPaul123 self-assigned this Oct 17, 2022
@DeveloperPaul123
Copy link
Owner Author

Proposed API

template<std::ranges::range Range>
void batch_enqueue_detach(Range&& tasks);

// a bit simplified
template<std::ranges::range Range, RangeValue, RangeValueReturnType>
std::vector<std::future<RangeValueReturnType>> batch_equeue(Range&& tasks);

The non-detached version will prove to be challenging but should be possible. With non-C++23 code, it will be a bit memory greedy with std::shared_ptr allocations but that is a necessary tradeoff unfortunately.

The other question that remains is should we create a way to be able to pass a range of input parameters to the range of tasks? If so, how would this look?

@DeveloperPaul123
Copy link
Owner Author

Since std::apply exists, we could just require that a range of values that is to be used as arguments is the same length as the input batch of tasks and that the value type of the range is tuple-like. In fact, the standard specifies

The tuple need not be std::tuple, and instead may be anything that supports std::get and std::tuple_size; in particular, std::array and std::pair may be used.

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

No branches or pull requests

1 participant