Insane_DNS/libraries/asio-1.28.1/doc/asio/overview/model/executors.html

105 lines
5.4 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Executors</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="../model.html" title="Asynchronous Model">
<link rel="prev" href="child_agents.html" title="Child Agents">
<link rel="next" href="allocators.html" title="Allocators">
<meta name="viewport" content="width=device-width, initial-scale=1">
</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="child_agents.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../model.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="allocators.html"><img src="../../../next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="asio.overview.model.executors"></a><a class="link" href="executors.html" title="Executors">Executors</a>
</h4></div></div></div>
<p>
Every asynchronous agent has an associated <span class="emphasis"><em>executor</em></span>.
An agent's executor determines how the agent's completion handlers are
queued and ultimately run.
</p>
<p>
Example uses of executors include:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
Coordinating a group of asynchronous agents that operate on shared
data structures, ensuring that the agents' completion handlers never
run concurrently<sup>[<a name="asio.overview.model.executors.f0" href="#ftn.asio.overview.model.executors.f0" class="footnote">5</a>]</sup>.
</li>
<li class="listitem">
Ensuring that agents are run on specified execution resource (e.g.
a CPU) that is proximal to data or an event source (e.g. a NIC).
</li>
<li class="listitem">
Denoting a group of related agents, and so enabling dynamic thread
pools to make smarter scheduling decisions (such as moving the agents
between execution resources as a unit).
</li>
<li class="listitem">
Queuing all completion handlers to run on a GUI application thread,
so that they may safely update user interface elements.
</li>
<li class="listitem">
Returning an asynchronous operation's default executor as-is, to run
completion handlers as close as possible to the event that triggered
the operation's completion.
</li>
<li class="listitem">
Adapting an asynchronous operation's default executor, to run code
before and after every completion handler, such as logging, user authorisation,
or exception handling.
</li>
<li class="listitem">
Specifying a priority for an asynchronous agent and its completion
handlers.
</li>
</ul></div>
<p>
The asynchronous operations within an asynchronous agent use the agent's
associated executor to:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
Track the existence of the work that the asynchronous operation represents,
while the operation is outstanding.
</li>
<li class="listitem">
Enqueue the completion handler for execution on completion of an operation.
</li>
<li class="listitem">
Ensure that completion handlers do not run re-entrantly, if doing so
might lead to inadvertent recursion and stack overflow.
</li>
</ul></div>
<p>
Thus, an asynchronous agent's associated executor represents a policy of
how, where, and when the agent should run, specified as a cross-cutting
concern to the code that makes up the agent.
</p>
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a name="ftn.asio.overview.model.executors.f0" href="#asio.overview.model.executors.f0" class="para">5</a>] </sup>
In Asio, this kind of executor is called a <a class="link" href="../core/strands.html" title="Strands: Use Threads Without Explicit Locking">strand</a>.
</p></div>
</div>
</div>
<div class="copyright-footer">Copyright © 2003-2023 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>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="child_agents.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../model.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="allocators.html"><img src="../../../next.png" alt="Next"></a>
</div>
</body>
</html>