mirror of
https://github.com/boostorg/cobalt.git
synced 2026-01-19 04:02:16 +00:00
31 lines
540 B
Plaintext
31 lines
540 B
Plaintext
[#run]
|
|
== cobalt/run.hpp
|
|
|
|
The `run` function is similar to <<spawn, spawn>> but running synchronously.
|
|
It will internally setup an execution context and the memory resources.
|
|
|
|
This can be useful when integrating a piece of cobalt code into a synchronous application.
|
|
|
|
[#run-outline]
|
|
=== Outline
|
|
|
|
[source,cpp]
|
|
----
|
|
// Run the task and return it's value or rethrow any exception.
|
|
T run(task<T> t);
|
|
----
|
|
|
|
[#run-example]
|
|
=== Example
|
|
|
|
[source,cpp]
|
|
----
|
|
cobalt::task<int> work();
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
return run(work());
|
|
}
|
|
----
|
|
|