74 lines
6.2 KiB
HTML
74 lines
6.2 KiB
HTML
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
|
<title>Service requirements</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="../reference.html" title="Reference">
|
||
|
<link rel="prev" href="Sender.html" title="Sender concepts">
|
||
|
<link rel="next" href="SettableSerialPortOption.html" title="Settable serial port option requirements">
|
||
|
<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="Sender.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="SettableSerialPortOption.html"><img src="../../next.png" alt="Next"></a>
|
||
|
</div>
|
||
|
<div class="section">
|
||
|
<div class="titlepage"><div><div><h3 class="title">
|
||
|
<a name="asio.reference.Service"></a><a class="link" href="Service.html" title="Service requirements">Service requirements</a>
|
||
|
</h3></div></div></div>
|
||
|
<p>
|
||
|
A class is a <span class="emphasis"><em>service</em></span> if it is publicly and unambiguously
|
||
|
derived from <code class="computeroutput"><span class="identifier">execution_context</span><span class="special">::</span><span class="identifier">service</span></code>,
|
||
|
or if it is publicly and unambiguously derived from another service. For
|
||
|
a service <code class="computeroutput"><span class="identifier">S</span></code>, <code class="computeroutput"><span class="identifier">S</span><span class="special">::</span><span class="identifier">key_type</span></code>
|
||
|
shall be valid and denote a type (C++Std [temp.deduct]), <code class="computeroutput"><span class="identifier">is_base_of_v</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">S</span><span class="special">::</span><span class="identifier">key_type</span><span class="special">,</span> <span class="identifier">S</span><span class="special">></span></code>
|
||
|
shall be <code class="computeroutput"><span class="keyword">true</span></code>, and <code class="computeroutput"><span class="identifier">S</span></code> shall satisfy the <code class="computeroutput"><span class="identifier">Destructible</span></code>
|
||
|
requirements (C++Std [destructible]).
|
||
|
</p>
|
||
|
<p>
|
||
|
The first parameter of all service constructors shall be an lvalue reference
|
||
|
to <code class="computeroutput"><span class="identifier">execution_context</span></code>. This
|
||
|
parameter denotes the <code class="computeroutput"><span class="identifier">execution_context</span></code>
|
||
|
object that represents a set of services, of which the service object will
|
||
|
be a member. [<span class="emphasis"><em>Note:</em></span> These constructors may be called
|
||
|
by the <code class="computeroutput"><span class="identifier">make_service</span></code> function.
|
||
|
—<span class="emphasis"><em>end note</em></span>]
|
||
|
</p>
|
||
|
<p>
|
||
|
A service shall provide an explicit constructor with a single parameter of
|
||
|
lvalue reference to <code class="computeroutput"><span class="identifier">execution_context</span></code>.
|
||
|
[<span class="emphasis"><em>Note:</em></span> This constructor may be called by the <code class="computeroutput"><span class="identifier">use_service</span></code> function. —<span class="emphasis"><em>end note</em></span>]
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">my_service</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">execution_context</span><span class="special">::</span><span class="identifier">service</span>
|
||
|
<span class="special">{</span>
|
||
|
<span class="keyword">public</span><span class="special">:</span>
|
||
|
<span class="keyword">typedef</span> <span class="identifier">my_service</span> <span class="identifier">key_type</span><span class="special">;</span>
|
||
|
<span class="keyword">explicit</span> <span class="identifier">my_service</span><span class="special">(</span><span class="identifier">execution_context</span><span class="special">&</span> <span class="identifier">ctx</span><span class="special">);</span>
|
||
|
<span class="identifier">my_service</span><span class="special">(</span><span class="identifier">execution_context</span><span class="special">&</span> <span class="identifier">ctx</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">some_value</span><span class="special">);</span>
|
||
|
<span class="keyword">private</span><span class="special">:</span>
|
||
|
<span class="keyword">virtual</span> <span class="keyword">void</span> <span class="identifier">shutdown</span><span class="special">()</span> <span class="keyword">noexcept</span> <span class="identifier">override</span><span class="special">;</span>
|
||
|
<span class="special">...</span>
|
||
|
<span class="special">};</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
A service's <code class="computeroutput"><span class="identifier">shutdown</span></code> member
|
||
|
function shall destroy all copies of user-defined function objects that are
|
||
|
held by the service.
|
||
|
</p>
|
||
|
</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="Sender.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="SettableSerialPortOption.html"><img src="../../next.png" alt="Next"></a>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|