Submit overloads

Synopses

Declared in <util/threadpool.h>

Enqueues a new task for asynchronous execution.

template<class F>
[[nodiscard, requires_capability(0x7f2e2046a3c8)]]
util::Expected<Future<F>, SubmitError>
Submit(F&& fn) noexcept;

Enqueues a range of tasks for asynchronous execution.

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;

Return Value

  • On success, a future containing fn's result. On failure, an error indicating why the task was rejected: ‐ SubmitError::Inactive: Pool has no workers (never started or already stopped). ‐ SubmitError::Interrupted: Pool task acceptance has been interrupted.

  • 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

fn

Callable to execute asynchronously.

fns

Callables to execute asynchronously.

Created with MrDocs