1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>execution_context::add_service</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="../execution_context.html" title="execution_context"> 9<link rel="prev" href="../execution_context.html" title="execution_context"> 10<link rel="next" href="destroy.html" title="execution_context::destroy"> 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="../execution_context.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../execution_context.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="destroy.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="boost_asio.reference.execution_context.add_service"></a><a class="link" href="add_service.html" title="execution_context::add_service">execution_context::add_service</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="boost_asio.indexterm.execution_context.add_service"></a> 31(Deprecated: 32 Use <code class="computeroutput">make_service()</code>.) Add a service object to the <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a>. 33 </p> 34<pre class="programlisting">template< 35 typename <a class="link" href="../Service.html" title="Service requirements">Service</a>> 36friend void add_service( 37 execution_context & e, 38 Service * svc); 39</pre> 40<p> 41 This function is used to add a service to the <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a>. 42 </p> 43<h6> 44<a name="boost_asio.reference.execution_context.add_service.h0"></a> 45 <span class="phrase"><a name="boost_asio.reference.execution_context.add_service.parameters"></a></span><a class="link" href="add_service.html#boost_asio.reference.execution_context.add_service.parameters">Parameters</a> 46 </h6> 47<div class="variablelist"> 48<p class="title"><b></b></p> 49<dl class="variablelist"> 50<dt><span class="term">e</span></dt> 51<dd><p> 52 The <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a> 53 object that owns the service. 54 </p></dd> 55<dt><span class="term">svc</span></dt> 56<dd> 57<p> 58 The service object. On success, ownership of the service object is 59 transferred to the <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a>. 60 When the <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a> 61 object is destroyed, it will destroy the service object by performing: 62</p> 63<pre class="programlisting">delete static_cast<execution_context::service*>(svc) 64</pre> 65<p> 66 </p> 67</dd> 68</dl> 69</div> 70<h6> 71<a name="boost_asio.reference.execution_context.add_service.h1"></a> 72 <span class="phrase"><a name="boost_asio.reference.execution_context.add_service.exceptions"></a></span><a class="link" href="add_service.html#boost_asio.reference.execution_context.add_service.exceptions">Exceptions</a> 73 </h6> 74<div class="variablelist"> 75<p class="title"><b></b></p> 76<dl class="variablelist"> 77<dt><span class="term">boost::asio::service_already_exists</span></dt> 78<dd><p> 79 Thrown if a service of the given type is already present in the 80 <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a>. 81 </p></dd> 82<dt><span class="term">boost::asio::invalid_service_owner</span></dt> 83<dd><p> 84 Thrown if the service's owning <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a> 85 is not the <a class="link" href="../execution_context.html" title="execution_context"><code class="computeroutput">execution_context</code></a> 86 object specified by the <code class="computeroutput">e</code> parameter. 87 </p></dd> 88</dl> 89</div> 90<h6> 91<a name="boost_asio.reference.execution_context.add_service.h2"></a> 92 <span class="phrase"><a name="boost_asio.reference.execution_context.add_service.requirements"></a></span><a class="link" href="add_service.html#boost_asio.reference.execution_context.add_service.requirements">Requirements</a> 93 </h6> 94<p> 95 <span class="emphasis"><em>Header: </em></span><code class="literal">boost/asio/execution_context.hpp</code> 96 </p> 97<p> 98 <span class="emphasis"><em>Convenience header: </em></span><code class="literal">boost/asio/execution.hpp</code> 99 </p> 100</div> 101<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 102<td align="left"></td> 103<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 104 Kohlhoff<p> 105 Distributed under the Boost Software License, Version 1.0. (See accompanying 106 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>) 107 </p> 108</div></td> 109</tr></table> 110<hr> 111<div class="spirit-nav"> 112<a accesskey="p" href="../execution_context.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../execution_context.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="destroy.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 113</div> 114</body> 115</html> 116