Skip to content

Commit

Permalink
Deploying to gh-pages from @ d01727f 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
dietmarkuehl committed Jan 20, 2025
1 parent 779c0c0 commit e04ca49
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 64 deletions.
136 changes: 136 additions & 0 deletions md_docs_intro_examples.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>beman::execution26: intro-examples</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="beman-logo.png"/></td>
<td id="projectalign">
<div id="projectname">beman::execution26
</div>
<div id="projectbrief">Building Block For Asynchronous Programs</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

</div><!-- top -->
<div><div class="header">
<div class="headertitle"><div class="title">intro-examples </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="autotoc_md0"></a>
Introduction by Example</h1>
<p>This page provides a series of examples showing how to use the <code>std::execution</code> components.</p>
<details >
<summary >
<code>"Hello, world"</code> - synchronous using asynchronous components</summary>
<p></p>
<p>Code: [<code>examples/intro-1-hello-world.cpp</code>]()</p>
<p>The first example is a very complicated way to a version of <code>"Hello,
world"</code>: it uses components for dealing with asynchronous work to synchronously produce the result. The intention is to show a basic use of some involved components to build up a feeling of how things work.</p>
<p>The componentes for <code>std::execution</code> are declared in the header <code>&lt;execution&gt;</code>. This particular implementation implements the cmponents in namespace <code><a class="el" href="namespacebeman_1_1execution26.html" title="Namespace for asynchronous operations and their vocabulary.">beman::execution26</a></code> declared in the header <code>&lt;<a class="el" href="execution_8hpp_source.html">beman/execution26/execution.hpp</a>&gt;</code>:</p>
<div class="fragment"><div class="line"> {c++}</div>
<div class="line">#include &lt;beman/execution26/execution.hpp&gt;</div>
<div class="line">#include &lt;iostream&gt;</div>
<div class="line">#include &lt;string&gt;</div>
<div class="line">#include &lt;tuple&gt;</div>
<div class="line"> </div>
<div class="line">namespace ex = ::beman::execution26;</div>
<div class="line">using namespace std::string_literals;</div>
</div><!-- fragment --><p>Most of these declarations should be familiar. The namespace alias <code>ex</code> is used to support easy migration to a different implementation, in particular the standard name <code>std::execution</code> once it becomes available with standard library implementations. The other examples will have a similar start which is only mentioned in the explanation to point out unusual parts like the use of custom components.</p>
<p>All interesting work happens in the <code>main</code> function:</p>
<div class="fragment"><div class="line"> {c++}</div>
<div class="line">int main()</div>
<div class="line">{</div>
<div class="line"> auto[result] = ex::sync_wait(</div>
<div class="line"> ex::when_all(</div>
<div class="line"> ex::just(&quot;hello, &quot;s),</div>
<div class="line"> ex::just(&quot;world&quot;s)</div>
<div class="line"> )</div>
<div class="line"> | ex::then([](auto s1, auto s2){ return s1 + s2; })</div>
<div class="line"> ).value_or(std::tuple(&quot;&quot;s));</div>
<div class="line"> </div>
<div class="line"> std::cout &lt;&lt; result &lt;&lt; &#39;\n&#39;;</div>
<div class="line">}</div>
</div><!-- fragment --><p>This code code be simpler even when using components from <code>std::execution</code>. Showing a few more components is intended to better reflect how an asynchronous program might look like. This examples uses a <em>sender factory</em> (<code>ex::just</code>), two <em>sender adaptors</em> (<code>ex::when_all</code> and <code>ex::then</code>), and finally a <em>sender consumer</em> (<code>ex::sync_wait</code>) to build up work and to execute it. The idea of a <em>sender</em> is that it represents work which can be composed with algorithms into a unit of work which is eventually executed.</p>
<p>Each work item can complete asynchronously at some later time, i.e., calling it like a function and using a returned value isn't really an option. Instead, when the work is started it does whatever is needed to get the work completed and get a <em>completion signal</em> delivered. Delivering a completion signal consists of calling a function on a suitable objects. The important part is that once work is started it always delivers exactly one completion signal which can indicate success, failure, or cancellation. Later examples for creating senders will go into more details about the cancellation signals.</p>
<p>The components used in this example do all of that synchronously:</p>
<ul>
<li><code>ex::just("string"s)</code> completes immediately when started with successful completion which includes the string passed as argument.</li>
<li><code>ex::when_all(<em>sender1</em>, <em>sender2</em>)</code> starts the senders passed as arguments. When all of the senders complete, it produces its own completion. In the case of success all the received values are passed to the completion signal. In case of an error all outstanding work is cancelled and the first error becomes <code>when_all</code>'s completion signal once all children have completed. Similarly, in case of cancellation all children get cancelled and once all complete <code>when_all</code> produces a cancellation signal. In the example the two children each produces one string as completion signal and <code>when_all</code> produces these two strings as its completion signal.</li>
<li><code><em>sender</em> | ex::then(<em>fun</em>)</code> is equivalent to using <code>ex::then(<em>sender</em>, <em>fun</em>)</code>. The <code>ex::then</code> calls the function <code><em>fun</em></code> with its child sender completes successful. The arguments to <code><em>fun</em></code> are the values received from the child completion signal. In the example, the child is <code>when_all(...)</code> and it produces two strings which are passed to <code><em>fun</em></code>. The completion signal of <code>ex::then</code> is successful with the value returned from the call to <code><em>fun</em></code> (which may <code>void</code>) if the call returns normally. If an exception is thrown <code>ex::then</code> completes with an <code>std::exception_ptr</code> to the exception thrown. In the example the completion is just a concatenation of the two strings.</li>
<li><code>sync_wait(<em>sender</em>)</code> starts its argument and then blocks until the work completes although the thread calling <code>sync_wait</code> may contribute to the completion of the work. The function returns a an <code>std::optional&lt;std::tuple&lt;<em>results</em>...&gt;&gt;</code>&gt;. If the child sender completes successfully the values from the child's completion signal become the elements of the tuple. If the child completes with an error, the error is thrown as an exception. Otherwise, if the work gets cancelled, an empty <code>std::optional&lt;...&gt;</code> is returned. In the example, the child sends a string which gets wrapped into a <code>std::tuple</code> which in turn gets wrapped into an <code>std::optional</code>. Thus, the somewhat round-about way to get the result: first using <code>value_or(std::tuple(""s))</code> to get the value from the <code>std::optional</code> which is then decomposed from the <code>std::tuple</code> using structured bindings.</li>
</ul>
<p></p>
</details>
<details >
<summary >
<code>"Hello, async"</code> - a simple asynchronous example</summary>
<p></p>
<p>Code: [<code>examples/intro-2-hello-async.cpp</code>]()</p>
<p></p>
</details>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6
</small></address>
</body>
</html>
22 changes: 11 additions & 11 deletions md_docs_overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
<div class="headertitle"><div class="title">overview </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="autotoc_md0"></a>
<div class="textblock"><h1><a class="anchor" id="autotoc_md1"></a>
std::execution Overview</h1>
<p>This page provides an overview of the components in <code>std::execution</code>. The documentation on this page doesn’t represent all details of the specification. However, it should capture enough details to be a suitable resource to determine how the various components are used.</p>
<p>For each of the components a summary view is provided. To get more details expand the respective section. </p>
<h2><a class="anchor" id="autotoc_md1"></a>
<h2><a class="anchor" id="autotoc_md2"></a>
Terms</h2>
<p>This section defines a few terms used throughout the description on this page. The terms aren’t taken from the specification and are, thus, somewhat informal.</p>
<details >
Expand All @@ -97,7 +97,7 @@ <h2><a class="anchor" id="autotoc_md1"></a>
environment</summary>
<p>The term <em>enviroment</em> refers to the bag of properties associated with an <code><em>object</em></code> by the call <code><a href="‘#get-env’">std::execution::get_env</a>(<em>object</em>)</code>. By default the environment for objects is empty (<code><a href="‘#empty-env’">std::execution::empty_env</a></code>). In particular, environments associated with <code><a href="‘#receiver’">receiver</a></code>s are used to provide access to properties like the <a href="‘#get-stop-token’">stop token</a>, <a href="‘#get-scheduler’">scheduler</a>, or <a href="‘#get-allocator’">allocator</a> associated with the <code><a href="‘#receiver’">receiver</a></code>. The various properties associated with an object are accessed via <a href="‘#queries’">queries</a>. </p>
</details>
<h2><a class="anchor" id="autotoc_md2"></a>
<h2><a class="anchor" id="autotoc_md3"></a>
Concepts</h2>
<p>This section lists the concepts from <code>std::execution</code>.</p>
<details >
Expand Down Expand Up @@ -414,7 +414,7 @@ <h2><a class="anchor" id="autotoc_md2"></a>
</details>
<p></code></p>
<p><code></code></p>
<h2><a class="anchor" id="autotoc_md3"></a>
<h2><a class="anchor" id="autotoc_md4"></a>
Queries</h2>
<p><code>The queries are used to obtain properties associated with and object. Except <code><a href="‘#forwarding-query’">forwarding_query</a></code> and <code><a href="‘#get-env’">get_env</a></code> the queries work on <a href="‘#environment’">environments</a>.</code></p>
<p><code></p><details >
Expand Down Expand Up @@ -470,7 +470,7 @@ <h2><a class="anchor" id="autotoc_md3"></a>
</details>
<p></code></p>
<p><code></code></p>
<h3><a class="anchor" id="autotoc_md4"></a>
<h3><a class="anchor" id="autotoc_md5"></a>
Customization Point Objects</h3>
<p><code></p><ul>
<li><code>connect(<em>sender, receiver</em>) -&gt; <em>operation_state</em></code></li>
Expand All @@ -481,10 +481,10 @@ <h3><a class="anchor" id="autotoc_md4"></a>
</ul>
<p></code></p>
<p><code></code></p>
<h2><a class="anchor" id="autotoc_md5"></a>
<h2><a class="anchor" id="autotoc_md6"></a>
Senders</h2>
<p><code> </code></p>
<h3><a class="anchor" id="autotoc_md6"></a>
<h3><a class="anchor" id="autotoc_md7"></a>
Sender Factories</h3>
<p><code></p><ul>
<li><code>just(<em>value...</em>) -&gt; <em>sender-of</em>&lt;set_value_t(<em>Value...</em>)&gt;</code></li>
Expand All @@ -495,7 +495,7 @@ <h3><a class="anchor" id="autotoc_md6"></a>
</ul>
<p></code></p>
<p><code></code></p>
<h3><a class="anchor" id="autotoc_md7"></a>
<h3><a class="anchor" id="autotoc_md8"></a>
Sender Adaptors</h3>
<p><code></p><ul>
<li><code>bulk</code></li>
Expand All @@ -518,14 +518,14 @@ <h3><a class="anchor" id="autotoc_md7"></a>
</ul>
<p></code></p>
<p><code></code></p>
<h3><a class="anchor" id="autotoc_md8"></a>
<h3><a class="anchor" id="autotoc_md9"></a>
Sender Consumers</h3>
<p><code></p><ul>
<li><code>sync_wait(<em>sender</em>) -&gt; std::optional&lt;std::tuple&lt;T...&gt;&gt;</code></li>
</ul>
<p></code></p>
<p><code></code></p>
<h2><a class="anchor" id="autotoc_md9"></a>
<h2><a class="anchor" id="autotoc_md10"></a>
Helpers</h2>
<p><code></p><ul>
<li><code>as_awaitable</code></li>
Expand Down Expand Up @@ -555,7 +555,7 @@ <h2><a class="anchor" id="autotoc_md9"></a>
</ul>
<p></code></p>
<p><code></code></p>
<h2><a class="anchor" id="autotoc_md10"></a>
<h2><a class="anchor" id="autotoc_md11"></a>
Stop Token</h2>
<p><code></p><ul>
<li><code>never_stop_token</code></li>
Expand Down
7 changes: 4 additions & 3 deletions pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@
<div class="contents">
<div class="textblock">Here is a list of all related documentation pages:</div><div class="directory">
<table class="directory">
<tr id="row_0_" class="even"><td class="entry"><span style="width:0px;display:inline-block;">&#160;</span><span id="arr_0_" class="arrow" onclick="toggleFolder('0_')">&#9658;</span><a class="el" href="md_docs_overview.html" target="_self">overview</a></td><td class="desc"></td></tr>
<tr id="row_1_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><a class="el" href="md_docs_questions.html" target="_self">Questions</a></td><td class="desc"></td></tr>
<tr id="row_2_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><a class="el" href="md_docs_TODO.html" target="_self">ToDo</a></td><td class="desc"></td></tr>
<tr id="row_0_" class="even"><td class="entry"><span style="width:0px;display:inline-block;">&#160;</span><span id="arr_0_" class="arrow" onclick="toggleFolder('0_')">&#9658;</span><a class="el" href="md_docs_intro_examples.html" target="_self">intro-examples</a></td><td class="desc"></td></tr>
<tr id="row_1_" class="odd"><td class="entry"><span style="width:0px;display:inline-block;">&#160;</span><span id="arr_1_" class="arrow" onclick="toggleFolder('1_')">&#9658;</span><a class="el" href="md_docs_overview.html" target="_self">overview</a></td><td class="desc"></td></tr>
<tr id="row_2_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><a class="el" href="md_docs_questions.html" target="_self">Questions</a></td><td class="desc"></td></tr>
<tr id="row_3_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><a class="el" href="md_docs_TODO.html" target="_self">ToDo</a></td><td class="desc"></td></tr>
</table>
</div><!-- directory -->
</div><!-- contents -->
Expand Down
3 changes: 2 additions & 1 deletion search/all_7.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ var searchData=
[
['inplace_5fstop_5fcallback_0',['inplace_stop_callback',['../classbeman_1_1execution26_1_1inplace__stop__callback.html',1,'beman::execution26']]],
['inplace_5fstop_5fsource_1',['inplace_stop_source',['../classbeman_1_1execution26_1_1inplace__stop__source.html',1,'beman::execution26']]],
['inplace_5fstop_5ftoken_2',['inplace_stop_token',['../classbeman_1_1execution26_1_1inplace__stop__token.html',1,'beman::execution26']]]
['inplace_5fstop_5ftoken_2',['inplace_stop_token',['../classbeman_1_1execution26_1_1inplace__stop__token.html',1,'beman::execution26']]],
['intro_2dexamples_3',['intro-examples',['../md_docs_intro_examples.html',1,'']]]
];
2 changes: 1 addition & 1 deletion search/pages_1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var searchData=
[
['overview_0',['overview',['../md_docs_overview.html',1,'']]]
['intro_2dexamples_0',['intro-examples',['../md_docs_intro_examples.html',1,'']]]
];
2 changes: 1 addition & 1 deletion search/pages_2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var searchData=
[
['questions_0',['Questions',['../md_docs_questions.html',1,'']]]
['overview_0',['overview',['../md_docs_overview.html',1,'']]]
];
2 changes: 1 addition & 1 deletion search/pages_3.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var searchData=
[
['todo_0',['ToDo',['../md_docs_TODO.html',1,'']]]
['questions_0',['Questions',['../md_docs_questions.html',1,'']]]
];
4 changes: 4 additions & 0 deletions search/pages_4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var searchData=
[
['todo_0',['ToDo',['../md_docs_TODO.html',1,'']]]
];
2 changes: 1 addition & 1 deletion search/searchdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var indexSectionsWithContent =
3: "a",
4: "cfjs",
5: "cef",
6: "aoqt",
6: "aioqt",
7: "b"
};

Expand Down
Loading

0 comments on commit e04ca49

Please sign in to comment.