Enqueues a range of tasks for asynchronous execution.
Synopsis
Declared in <util/threadpool.h>
template<std::ranges::sized_range R>
requires (!std::is_lvalue_reference_v<R>)
[[nodiscard, requires_capability(0x7f2e2046a4d8)]]
util::Expected<std::vector<RangeFuture<R>>, SubmitError>
Submit(R&& fns) noexcept;
Description
This is more efficient when submitting many tasks at once, since the queue lock is only taken once internally and all worker threads are notified. For single tasks, Submit() is preferred since only one worker thread is notified.
Thread‐safe: Can be called from any thread, including within submitted callables.
|
Warning
|
Ignoring the returned futures requires guarding tasks against uncaught exceptions, as they would otherwise be silently discarded. |
Return Value
On success, a vector of futures containing each element of fns's result in order. On failure, an error indicating why the range was rejected: ‐ SubmitError::Inactive: Pool has no workers (never started or already stopped). ‐ SubmitError::Interrupted: Pool task acceptance has been interrupted.
|
Note
|
The return value should not be discarded. |
Parameters
Name |
Description |
fns |
Callables to execute asynchronously. |
Created with MrDocs