[#ThreadPool-Submit-05]
= xref:ThreadPool.adoc[ThreadPool]::Submit
:relfileprefix: ../
:mrdocs:

`Submit` overloads

== Synopses

Declared in `&lt;util&sol;threadpool&period;h&gt;`

Enqueues a new task for asynchronous execution&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class F&gt;
&lsqb;&lsqb;nodiscard, requires&lowbar;capability(0x7f2e2046a3c8)&rsqb;&rsqb;
xref:util/Expected-0b.adoc[util::Expected&lt;Future&lt;F&gt;, SubmitError&gt;]
xref:ThreadPool/Submit-09a.adoc[Submit](F&& fn) noexcept;
----

[.small]#xref:ThreadPool/Submit-09a.adoc[_» more&period;&period;&period;_]#

Enqueues a range of tasks for asynchronous execution&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;std::ranges::sized&lowbar;range R&gt;
requires (!std&colon;&colon;is&lowbar;lvalue&lowbar;reference&lowbar;v&lt;R&gt;)
&lsqb;&lsqb;nodiscard, requires&lowbar;capability(0x7f2e2046a4d8)&rsqb;&rsqb;
xref:util/Expected-0b.adoc[util::Expected&lt;std::vector&lt;RangeFuture&lt;R&gt;&gt;, SubmitError&gt;]
xref:ThreadPool/Submit-09b.adoc[Submit](R&& fns) noexcept;
----

[.small]#xref:ThreadPool/Submit-09b.adoc[_» more&period;&period;&period;_]#

== Return Value

* On success, a future containing fn&apos;s result&period; On failure, an error indicating why the task was rejected&colon; &hyphen; SubmitError&colon;&colon;Inactive&colon; Pool has no workers (never started or already stopped)&period; &hyphen; SubmitError&colon;&colon;Interrupted&colon; Pool task acceptance has been interrupted&period;
* On success, a vector of futures containing each element of fns&apos;s result in order&period; On failure, an error indicating why the range was rejected&colon; &hyphen; SubmitError&colon;&colon;Inactive&colon; Pool has no workers (never started or already stopped)&period; &hyphen; SubmitError&colon;&colon;Interrupted&colon; Pool task acceptance has been interrupted&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *fn*
| Callable to execute asynchronously&period;
| *fns*
| Callables to execute asynchronously&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
