ThreadPool::Submit

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;
» more...

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;
» more...

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

NameDescription
fnCallable to execute asynchronously.
fnsCallables to execute asynchronously.