Enqueues a new task for asynchronous execution.
Declared in <util/threadpool.h>
template<class F>
[[nodiscard, requires_capability(0x7f2e2046a3c8)]]
util::Expected<Future<F>, SubmitError>
Submit(F&& fn) noexcept;
Thread-safe: Can be called from any thread, including within the provided 'fn' callable.
Ignoring the returned future requires guarding the task against uncaught exceptions, as they would otherwise be silently discarded.
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.
The return value should not be discarded.
| Name | Description |
|---|---|
| fn | Callable to execute asynchronously. |