overload1.html 5.58 KB
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>io_context::run (1 of 2 overloads)</title>
<link rel="stylesheet" href="../../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../../index.html" title="Asio">
<link rel="up" href="../run.html" title="io_context::run">
<link rel="prev" href="../run.html" title="io_context::run">
<link rel="next" href="overload2.html" title="io_context::run (2 of 2 overloads)">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../../../asio.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../run.html"><img src="../../../../prev.png" alt="Prev"></a><a accesskey="u" href="../run.html"><img src="../../../../up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../home.png" alt="Home"></a><a accesskey="n" href="overload2.html"><img src="../../../../next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="asio.reference.io_context.run.overload1"></a><a class="link" href="overload1.html" title="io_context::run (1 of 2 overloads)">io_context::run
          (1 of 2 overloads)</a>
</h5></div></div></div>
<p>
            Run the <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a>
            object's event processing loop.
          </p>
<pre class="programlisting">count_type run();
</pre>
<p>
            The <code class="computeroutput">run()</code> function blocks until all work has finished and
            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>
            has been stopped.
          </p>
<p>
            Multiple threads may call the <code class="computeroutput">run()</code> function to set up a
            pool of threads from which the <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a>
            may execute handlers. All threads that are waiting in the pool are equivalent
            and the <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a>
            may choose any one of them to invoke a handler.
          </p>
<p>
            A normal exit from the <code class="computeroutput">run()</code> function implies that the
            <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a>
            object is stopped (the <code class="computeroutput">stopped()</code> function returns <code class="computeroutput">true</code>).
            Subsequent calls to <code class="computeroutput">run()</code>, <code class="computeroutput">run_one()</code>, <code class="computeroutput">poll()</code>
            or <code class="computeroutput">poll_one()</code> will return immediately unless there is a
            prior call to <code class="computeroutput">restart()</code>.
          </p>
<h6>
<a name="asio.reference.io_context.run.overload1.h0"></a>
            <span><a name="asio.reference.io_context.run.overload1.return_value"></a></span><a class="link" href="overload1.html#asio.reference.io_context.run.overload1.return_value">Return
            Value</a>
          </h6>
<p>
            The number of handlers that were executed.
          </p>
<h6>
<a name="asio.reference.io_context.run.overload1.h1"></a>
            <span><a name="asio.reference.io_context.run.overload1.remarks"></a></span><a class="link" href="overload1.html#asio.reference.io_context.run.overload1.remarks">Remarks</a>
          </h6>
<p>
            Calling the <code class="computeroutput">run()</code> function from a thread that is currently
            calling one of <code class="computeroutput">run()</code>, <code class="computeroutput">run_one()</code>, <code class="computeroutput">run_for()</code>,
            <code class="computeroutput">run_until()</code>, <code class="computeroutput">poll()</code> or <code class="computeroutput">poll_one()</code>
            on the same <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a>
            object may introduce the potential for deadlock. It is the caller's reponsibility
            to avoid this.
          </p>
<p>
            The <code class="computeroutput">poll()</code> function may also be used to dispatch ready handlers,
            but without blocking.
          </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
      Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        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>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../run.html"><img src="../../../../prev.png" alt="Prev"></a><a accesskey="u" href="../run.html"><img src="../../../../up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../home.png" alt="Home"></a><a accesskey="n" href="overload2.html"><img src="../../../../next.png" alt="Next"></a>
</div>
</body>
</html>