1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>io_context::run (1 of 2 overloads)</title> 5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../../boost_asio.html" title="Boost.Asio"> 8<link rel="up" href="../run.html" title="io_context::run"> 9<link rel="prev" href="../run.html" title="io_context::run"> 10<link rel="next" href="overload2.html" title="io_context::run (2 of 2 overloads)"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="../run.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../run.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../boost_asio.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="overload2.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="boost_asio.reference.io_context.run.overload1"></a><a class="link" href="overload1.html" title="io_context::run (1 of 2 overloads)">io_context::run 28 (1 of 2 overloads)</a> 29</h5></div></div></div> 30<p> 31 Run the <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 32 object's event processing loop. 33 </p> 34<pre class="programlisting">count_type run(); 35</pre> 36<p> 37 The <code class="computeroutput">run()</code> function blocks until all work has finished and 38 there are no more handlers to be dispatched, or until the <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 39 has been stopped. 40 </p> 41<p> 42 Multiple threads may call the <code class="computeroutput">run()</code> function to set up a 43 pool of threads from which the <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 44 may execute handlers. All threads that are waiting in the pool are equivalent 45 and the <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 46 may choose any one of them to invoke a handler. 47 </p> 48<p> 49 A normal exit from the <code class="computeroutput">run()</code> function implies that the 50 <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 51 object is stopped (the <code class="computeroutput">stopped()</code> function returns <code class="computeroutput">true</code>). 52 Subsequent calls to <code class="computeroutput">run()</code>, <code class="computeroutput">run_one()</code>, <code class="computeroutput">poll()</code> 53 or <code class="computeroutput">poll_one()</code> will return immediately unless there is a 54 prior call to <code class="computeroutput">restart()</code>. 55 </p> 56<h6> 57<a name="boost_asio.reference.io_context.run.overload1.h0"></a> 58 <span class="phrase"><a name="boost_asio.reference.io_context.run.overload1.return_value"></a></span><a class="link" href="overload1.html#boost_asio.reference.io_context.run.overload1.return_value">Return 59 Value</a> 60 </h6> 61<p> 62 The number of handlers that were executed. 63 </p> 64<h6> 65<a name="boost_asio.reference.io_context.run.overload1.h1"></a> 66 <span class="phrase"><a name="boost_asio.reference.io_context.run.overload1.remarks"></a></span><a class="link" href="overload1.html#boost_asio.reference.io_context.run.overload1.remarks">Remarks</a> 67 </h6> 68<p> 69 Calling the <code class="computeroutput">run()</code> function from a thread that is currently 70 calling one of <code class="computeroutput">run()</code>, <code class="computeroutput">run_one()</code>, <code class="computeroutput">run_for()</code>, 71 <code class="computeroutput">run_until()</code>, <code class="computeroutput">poll()</code> or <code class="computeroutput">poll_one()</code> 72 on the same <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 73 object may introduce the potential for deadlock. It is the caller's reponsibility 74 to avoid this. 75 </p> 76<p> 77 The <code class="computeroutput">poll()</code> function may also be used to dispatch ready handlers, 78 but without blocking. 79 </p> 80</div> 81<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 82<td align="left"></td> 83<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 84 Kohlhoff<p> 85 Distributed under the Boost Software License, Version 1.0. (See accompanying 86 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 87 </p> 88</div></td> 89</tr></table> 90<hr> 91<div class="spirit-nav"> 92<a accesskey="p" href="../run.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../run.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../boost_asio.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="overload2.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 93</div> 94</body> 95</html> 96