1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 3<title>Coroutine awaitables - Boost.Outcome documentation</title> 4<link rel="stylesheet" href="../../../css/boost.css" type="text/css"> 5<meta name="generator" content="Hugo 0.52 with Boostdoc theme"> 6<meta name="viewport" content="width=device-width,initial-scale=1.0"/> 7 8<link rel="icon" href="../../../images/favicon.ico" type="image/ico"/> 9<body><div class="spirit-nav"> 10<a accesskey="p" href="../../../tutorial/essential/coroutines/try.html"><img src="../../../images/prev.png" alt="Prev"></a> 11 <a accesskey="u" href="../../../tutorial/essential/coroutines.html"><img src="../../../images/up.png" alt="Up"></a> 12 <a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="../../../tutorial/essential/coroutines/returning.html"><img src="../../../images/next.png" alt="Next"></a></div><div id="content"> 13 <div class="titlepage"><div><div><h1 style="clear: both">Coroutine awaitables</h1></div></div></div> 14 <p>The second part of the support is provided by header <code><boost/outcome/coroutine_support.hpp></code> 15(or <code><boost/outcome/experimental/coroutine_support.hpp></code> if you want Coroutine support for 16Experimental Outcome). This adds into namespace <code>BOOST_OUTCOME_V2_NAMESPACE::awaitables</code> (or 17<code>BOOST_OUTCOME_V2_NAMESPACE::experimental::awaitables</code>) these awaitable types suitable 18for returning from a Coroutinised function:</p> 19 20<ul> 21<li><a href="../../../reference/types/awaitables/eager.html" class="api-reference"><code>eager<T></code></a> 22 23 24<p>An eagerly evaluated Coroutine: invoking <code>co_await</code> upon a function returning one 25of these immediately begins the execution of the function now. If the function never 26suspends, the overhead is similar to calling an ordinary function.</p></li> 27 28<li><a href="../../../reference/types/awaitables/lazy.html" class="api-reference"><code>lazy<T></code></a> 29 30 31<p>A lazily evaluated Coroutine (often named <code>task<T></code> in most C++ Coroutine 32literature): invoking <code>co_await</code> upon a function returning one of these causes the 33function to be immediately suspended as soon as execution begins. Only resuming 34the execution of the coroutine proceeds execution.</p></li> 35 36<li><p><code>atomic_eager<T></code></p> 37 38<p><code>eager<T></code> does not employ thread synchronisation during resumption of dependent 39coroutines which is fine if you do not traverse kernel threads during a 40suspend-resume cycle. If you do however potentially traverse kernel threads 41during suspend-resume, you ought to use <code>atomic_eager<T></code> instead – this uses 42atomics to synchronise the setting and checking of state to ensure correctness.</p></li> 43 44<li><p><code>atomic_lazy<T></code></p> 45 46<p>Same for <code>lazy<T></code> as <code>atomic_eager<T></code> is for <code>eager<T></code>.</p></li> 47</ul> 48 49 50 </div><p><small>Last revised: April 07, 2020 at 10:22:38 +0100</small></p> 51<hr> 52<div class="spirit-nav"> 53<a accesskey="p" href="../../../tutorial/essential/coroutines/try.html"><img src="../../../images/prev.png" alt="Prev"></a> 54 <a accesskey="u" href="../../../tutorial/essential/coroutines.html"><img src="../../../images/up.png" alt="Up"></a> 55 <a accesskey="h" href="../../../index.html"><img src="../../../images/home.png" alt="Home"></a><a accesskey="n" href="../../../tutorial/essential/coroutines/returning.html"><img src="../../../images/next.png" alt="Next"></a></div></body> 56</html> 57