Files
rippled/yield__to_8h_source.html
2025-11-04 00:36:48 -08:00

250 lines
34 KiB
HTML

<!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.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>rippled: yield_to.h Source File</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="projectalign">
<div id="projectname">rippled
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<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>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
<!-- 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 id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_0103a8ad82dcc2c51f5cde661b4b5cb7.html">xrpl</a></li><li class="navelem"><a class="el" href="dir_31b47b71b675f5c4d1b67be42516b2a9.html">beast</a></li><li class="navelem"><a class="el" href="dir_e010efe075c677e60f9f2b7391ebd7a4.html">test</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">yield_to.h</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">// Distributed under the Boost Software License, Version 1.0. (See accompanying</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="comment">// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="comment">//</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span> </div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="preprocessor">#ifndef BEAST_TEST_YIELD_TO_HPP</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="preprocessor">#define BEAST_TEST_YIELD_TO_HPP</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span> </div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="preprocessor">#include &lt;boost/asio/executor_work_guard.hpp&gt;</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="preprocessor">#include &lt;boost/asio/io_context.hpp&gt;</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="preprocessor">#include &lt;boost/asio/spawn.hpp&gt;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="preprocessor">#include &lt;boost/optional.hpp&gt;</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="preprocessor">#include &lt;boost/thread/csbl/memory/allocator_arg.hpp&gt;</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> </div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/condition_variable.html">condition_variable</a>&gt;</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/mutex.html">mutex</a>&gt;</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/thread.html">thread</a>&gt;</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span><span class="preprocessor">#include &lt;<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/vector.html">vector</a>&gt;</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> </div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacebeast.html">beast</a> {</div>
<div class="foldopen" id="foldopen00020" data-start="{" data-end="}">
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"><a class="line" href="namespacebeast_1_1test.html"> 20</a></span><span class="keyword">namespace </span>test {</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> </div>
<div class="foldopen" id="foldopen00028" data-start="{" data-end="};">
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html"> 28</a></span><span class="keyword">class </span><a class="code hl_class" href="classbeast_1_1test_1_1enable__yield__to.html">enable_yield_to</a></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span>{</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span><span class="keyword">protected</span>:</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#ab78916dc37b3ac29c51a2f6db6c8dcc3"> 31</a></span> boost::asio::io_context <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#ab78916dc37b3ac29c51a2f6db6c8dcc3">ios_</a>;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> boost::optional&lt;boost::asio::executor_work_guard&lt;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> boost::asio::io_context::executor_type&gt;&gt;</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#af042834c1812ab7365316ae76030b9ec"> 36</a></span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#af042834c1812ab7365316ae76030b9ec">work_</a>;</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#aca4940910f75e655a6d47d8363496fbc"> 37</a></span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;std::thread&gt;</a> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#aca4940910f75e655a6d47d8363496fbc">threads_</a>;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#a3f6b147fb7df18f9344cfd33b68305ee"> 38</a></span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/thread/mutex.html">std::mutex</a> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a3f6b147fb7df18f9344cfd33b68305ee">m_</a>;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#a52f1f5d44106a2a01bd690cf5791542f"> 39</a></span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/thread/condition_variable.html">std::condition_variable</a> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a52f1f5d44106a2a01bd690cf5791542f">cv_</a>;</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#a2f3d805b9b02be4d295ee8e66c21a47e"> 40</a></span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a2f3d805b9b02be4d295ee8e66c21a47e">running_</a> = 0;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#a431255178ff3bda7a31296d830d5c504"> 44</a></span> <span class="keyword">using </span><a class="code hl_typedef" href="classbeast_1_1test_1_1enable__yield__to.html#a431255178ff3bda7a31296d830d5c504">yield_context</a> = boost::asio::yield_context;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> </div>
<div class="foldopen" id="foldopen00046" data-start="{" data-end="}">
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#a28026f7d95dd5784e15b6985953f6912"> 46</a></span> <span class="keyword">explicit</span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#a28026f7d95dd5784e15b6985953f6912">enable_yield_to</a>(<a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a> concurrency = 1)</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> : <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#af042834c1812ab7365316ae76030b9ec">work_</a>(<a class="code hl_namespace" href="namespaceboost.html">boost</a>::asio::make_work_guard(<a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#ab78916dc37b3ac29c51a2f6db6c8dcc3">ios_</a>))</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> {</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#aca4940910f75e655a6d47d8363496fbc">threads_</a>.<a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/container/vector/reserve.html">reserve</a>(concurrency);</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <span class="keywordflow">while</span> (concurrency--)</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#aca4940910f75e655a6d47d8363496fbc">threads_</a>.<a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/container/vector/emplace_back.html">emplace_back</a>([&amp;] { <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#ab78916dc37b3ac29c51a2f6db6c8dcc3">ios_</a>.run(); });</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> }</div>
</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> </div>
<div class="foldopen" id="foldopen00054" data-start="{" data-end="}">
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#aaabb0659d5957fcafde65bc87870dd57"> 54</a></span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#aaabb0659d5957fcafde65bc87870dd57">~enable_yield_to</a>()</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> {</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#af042834c1812ab7365316ae76030b9ec">work_</a> = boost::none;</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="keywordflow">for</span> (<span class="keyword">auto</span>&amp; t : <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#aca4940910f75e655a6d47d8363496fbc">threads_</a>)</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> t.join();</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> }</div>
</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> </div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> boost::asio::io_context&amp;</div>
<div class="foldopen" id="foldopen00063" data-start="{" data-end="}">
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#a240c1cf70fb6261937e75b45fee0d1a8"> 63</a></span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#a240c1cf70fb6261937e75b45fee0d1a8">get_io_context</a>()</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> {</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#ab78916dc37b3ac29c51a2f6db6c8dcc3">ios_</a>;</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> }</div>
</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> </div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span><span class="preprocessor">#if BEAST_DOXYGEN</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="keyword">template</span> &lt;<span class="keyword">class</span>... FN&gt;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <span class="keywordtype">void</span></div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#a611cd725aff174c8578d112a122fe419">yield_to</a>(FN&amp;&amp;... fn);</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <span class="keyword">template</span> &lt;<span class="keyword">class </span>F0, <span class="keyword">class</span>... FN&gt;</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <span class="keywordtype">void</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#a611cd725aff174c8578d112a122fe419">yield_to</a>(F0&amp;&amp; f0, FN&amp;&amp;... fn);</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> </div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span> <span class="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00091" data-start="{" data-end="}">
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#ac043a57142d6c9afd9b608c732de6992"> 91</a></span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#ac043a57142d6c9afd9b608c732de6992">spawn</a>()</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> {</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> }</div>
</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <span class="keyword">template</span> &lt;<span class="keyword">class </span>F0, <span class="keyword">class</span>... FN&gt;</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordtype">void</span></div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#ac043a57142d6c9afd9b608c732de6992">spawn</a>(F0&amp;&amp; f, FN&amp;&amp;... fn);</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span>};</div>
</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> </div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span><span class="keyword">template</span> &lt;<span class="keyword">class </span>F0, <span class="keyword">class</span>... FN&gt;</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span><span class="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00102" data-start="{" data-end="}">
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#a611cd725aff174c8578d112a122fe419"> 102</a></span><a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#a611cd725aff174c8578d112a122fe419">enable_yield_to::yield_to</a>(F0&amp;&amp; f0, FN&amp;&amp;... fn)</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span>{</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a2f3d805b9b02be4d295ee8e66c21a47e">running_</a> = 1 + <span class="keyword">sizeof</span>...(FN);</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#ac043a57142d6c9afd9b608c732de6992">spawn</a>(f0, fn...);</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock&lt;std::mutex&gt;</a> lock{<a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a3f6b147fb7df18f9344cfd33b68305ee">m_</a>};</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a52f1f5d44106a2a01bd690cf5791542f">cv_</a>.<a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/thread/condition_variable/wait.html">wait</a>(lock, [&amp;] { <span class="keywordflow">return</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a2f3d805b9b02be4d295ee8e66c21a47e">running_</a> == 0; });</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span>}</div>
</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> </div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span><span class="keyword">template</span> &lt;<span class="keyword">class </span>F0, <span class="keyword">class</span>... FN&gt;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span><span class="keyword">inline</span> <span class="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00112" data-start="{" data-end="}">
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"><a class="line" href="classbeast_1_1test_1_1enable__yield__to.html#ae5e5e8c703a37a75b53d23490d28c741"> 112</a></span><a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#ac043a57142d6c9afd9b608c732de6992">enable_yield_to::spawn</a>(F0&amp;&amp; f, FN&amp;&amp;... fn)</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span>{</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> boost::asio::spawn(</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#ab78916dc37b3ac29c51a2f6db6c8dcc3">ios_</a>,</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> boost::allocator_arg,</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> boost::context::fixedsize_stack(2 * 1024 * 1024),</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> [&amp;](<a class="code hl_typedef" href="classbeast_1_1test_1_1enable__yield__to.html#a431255178ff3bda7a31296d830d5c504">yield_context</a> yield) {</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> f(yield);</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> <a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/thread/lock_guard.html">std::lock_guard</a> lock{<a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a3f6b147fb7df18f9344cfd33b68305ee">m_</a>};</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <span class="keywordflow">if</span> (--<a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a2f3d805b9b02be4d295ee8e66c21a47e">running_</a> == 0)</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> <a class="code hl_variable" href="classbeast_1_1test_1_1enable__yield__to.html#a52f1f5d44106a2a01bd690cf5791542f">cv_</a>.<a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/thread/condition_variable/notify_all.html">notify_all</a>();</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> },</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> [](<a class="code hl_classRef" href="http://en.cppreference.com/w/cpp/error/exception_ptr.html">std::exception_ptr</a> e) {</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="keywordflow">if</span> (e)</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> <a class="code hl_functionRef" href="http://en.cppreference.com/w/cpp/error/rethrow_exception.html">std::rethrow_exception</a>(e);</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> });</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> <a class="code hl_function" href="classbeast_1_1test_1_1enable__yield__to.html#ac043a57142d6c9afd9b608c732de6992">spawn</a>(fn...);</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span>}</div>
</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> </div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span>} <span class="comment">// namespace test</span></div>
</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span>} <span class="comment">// namespace beast</span></div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> </div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html">beast::test::enable_yield_to</a></div><div class="ttdoc">Mix-in to support tests using asio coroutines.</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00028">yield_to.h:29</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_a240c1cf70fb6261937e75b45fee0d1a8"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#a240c1cf70fb6261937e75b45fee0d1a8">beast::test::enable_yield_to::get_io_context</a></div><div class="ttdeci">boost::asio::io_context &amp; get_io_context()</div><div class="ttdoc">Return the io_context associated with the object.</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00063">yield_to.h:63</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_a28026f7d95dd5784e15b6985953f6912"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#a28026f7d95dd5784e15b6985953f6912">beast::test::enable_yield_to::enable_yield_to</a></div><div class="ttdeci">enable_yield_to(std::size_t concurrency=1)</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00046">yield_to.h:46</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_a2f3d805b9b02be4d295ee8e66c21a47e"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#a2f3d805b9b02be4d295ee8e66c21a47e">beast::test::enable_yield_to::running_</a></div><div class="ttdeci">std::size_t running_</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00040">yield_to.h:40</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_a3f6b147fb7df18f9344cfd33b68305ee"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#a3f6b147fb7df18f9344cfd33b68305ee">beast::test::enable_yield_to::m_</a></div><div class="ttdeci">std::mutex m_</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00038">yield_to.h:38</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_a431255178ff3bda7a31296d830d5c504"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#a431255178ff3bda7a31296d830d5c504">beast::test::enable_yield_to::yield_context</a></div><div class="ttdeci">boost::asio::yield_context yield_context</div><div class="ttdoc">The type of yield context passed to functions.</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00044">yield_to.h:44</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_a52f1f5d44106a2a01bd690cf5791542f"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#a52f1f5d44106a2a01bd690cf5791542f">beast::test::enable_yield_to::cv_</a></div><div class="ttdeci">std::condition_variable cv_</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00039">yield_to.h:39</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_a611cd725aff174c8578d112a122fe419"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#a611cd725aff174c8578d112a122fe419">beast::test::enable_yield_to::yield_to</a></div><div class="ttdeci">void yield_to(F0 &amp;&amp;f0, FN &amp;&amp;... fn)</div><div class="ttdoc">Run one or more functions, each in a coroutine.</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00102">yield_to.h:102</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_aaabb0659d5957fcafde65bc87870dd57"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#aaabb0659d5957fcafde65bc87870dd57">beast::test::enable_yield_to::~enable_yield_to</a></div><div class="ttdeci">~enable_yield_to()</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00054">yield_to.h:54</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_ab78916dc37b3ac29c51a2f6db6c8dcc3"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#ab78916dc37b3ac29c51a2f6db6c8dcc3">beast::test::enable_yield_to::ios_</a></div><div class="ttdeci">boost::asio::io_context ios_</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00031">yield_to.h:31</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_ac043a57142d6c9afd9b608c732de6992"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#ac043a57142d6c9afd9b608c732de6992">beast::test::enable_yield_to::spawn</a></div><div class="ttdeci">void spawn()</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00091">yield_to.h:91</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_aca4940910f75e655a6d47d8363496fbc"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#aca4940910f75e655a6d47d8363496fbc">beast::test::enable_yield_to::threads_</a></div><div class="ttdeci">std::vector&lt; std::thread &gt; threads_</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00037">yield_to.h:37</a></div></div>
<div class="ttc" id="aclassbeast_1_1test_1_1enable__yield__to_html_af042834c1812ab7365316ae76030b9ec"><div class="ttname"><a href="classbeast_1_1test_1_1enable__yield__to.html#af042834c1812ab7365316ae76030b9ec">beast::test::enable_yield_to::work_</a></div><div class="ttdeci">boost::optional&lt; boost::asio::executor_work_guard&lt; boost::asio::io_context::executor_type &gt; &gt; work_</div><div class="ttdef"><b>Definition</b> <a href="yield__to_8h_source.html#l00036">yield_to.h:36</a></div></div>
<div class="ttc" id="acondition_variable_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/condition_variable.html">condition_variable</a></div></div>
<div class="ttc" id="aemplace_back_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back.html">std::vector::emplace_back</a></div><div class="ttdeci">T emplace_back(T... args)</div></div>
<div class="ttc" id="aexception_ptr_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/error/exception_ptr.html">std::exception_ptr</a></div></div>
<div class="ttc" id="alock_guard_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/thread/lock_guard.html">std::lock_guard</a></div></div>
<div class="ttc" id="amutex_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/mutex.html">mutex</a></div></div>
<div class="ttc" id="anamespacebeast_html"><div class="ttname"><a href="namespacebeast.html">beast</a></div><div class="ttdef"><b>Definition</b> <a href="base__uint_8h_source.html#l00653">base_uint.h:653</a></div></div>
<div class="ttc" id="anamespaceboost_html"><div class="ttname"><a href="namespaceboost.html">boost</a></div><div class="ttdef"><b>Definition</b> <a href="IPAddress_8h_source.html#l00086">IPAddress.h:86</a></div></div>
<div class="ttc" id="anotify_all_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/thread/condition_variable/notify_all.html">std::condition_variable::notify_all</a></div><div class="ttdeci">T notify_all(T... args)</div></div>
<div class="ttc" id="areserve_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector/reserve.html">std::vector::reserve</a></div><div class="ttdeci">T reserve(T... args)</div></div>
<div class="ttc" id="arethrow_exception_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/error/rethrow_exception.html">std::rethrow_exception</a></div><div class="ttdeci">T rethrow_exception(T... args)</div></div>
<div class="ttc" id="asize_t_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a></div></div>
<div class="ttc" id="athread_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/thread.html">thread</a></div></div>
<div class="ttc" id="aunique_lock_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/thread/unique_lock.html">std::unique_lock</a></div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/vector.html">vector</a></div></div>
<div class="ttc" id="await_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/thread/condition_variable/wait.html">std::condition_variable::wait</a></div><div class="ttdeci">T wait(T... args)</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- 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.8
</small></address>
</body>
</html>