| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> |
| <title>io_service::~io_service</title> |
| <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <link rel="home" href="../../../boost_asio.html" title="Boost.Asio"> |
| <link rel="up" href="../io_service.html" title="io_service"> |
| <link rel="prev" href="wrap.html" title="io_service::wrap"> |
| <link rel="next" href="../io_service__id.html" title="io_service::id"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table cellpadding="2" width="100%"><tr> |
| <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> |
| <td align="center"><a href="../../../../../index.html">Home</a></td> |
| <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> |
| <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> |
| <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> |
| <td align="center"><a href="../../../../../more/index.htm">More</a></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="wrap.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../io_service.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="../io_service__id.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h4 class="title"> |
| <a name="boost_asio.reference.io_service._io_service"></a><a class="link" href="_io_service.html" title="io_service::~io_service">io_service::~io_service</a> |
| </h4></div></div></div> |
| <p> |
| <a class="indexterm" name="id1163758"></a> |
| Destructor. |
| </p> |
| <pre class="programlisting"><span class="special">~</span><span class="identifier">io_service</span><span class="special">();</span> |
| </pre> |
| <p> |
| On destruction, the <a class="link" href="../io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a> performs the following |
| sequence of operations: |
| </p> |
| <div class="itemizedlist"><ul class="itemizedlist" type="disc"> |
| <li class="listitem"> |
| For each service object <code class="computeroutput"><span class="identifier">svc</span></code> |
| in the <a class="link" href="../io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a> set, in reverse |
| order of the beginning of service object lifetime, performs <code class="computeroutput"><span class="identifier">svc</span><span class="special">-></span><span class="identifier">shutdown_service</span><span class="special">()</span></code>. |
| </li> |
| <li class="listitem"> |
| Uninvoked handler objects that were scheduled for deferred invocation |
| on the <a class="link" href="../io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a>, or any associated |
| strand, are destroyed. |
| </li> |
| <li class="listitem"> |
| For each service object <code class="computeroutput"><span class="identifier">svc</span></code> |
| in the <a class="link" href="../io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a> set, in reverse |
| order of the beginning of service object lifetime, performs <code class="computeroutput"><span class="keyword">delete</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">io_service</span><span class="special">::</span><span class="identifier">service</span><span class="special">*>(</span><span class="identifier">svc</span><span class="special">)</span></code>. |
| </li> |
| </ul></div> |
| <a name="boost_asio.reference.io_service._io_service.remarks"></a><h6> |
| <a name="id1163982"></a> |
| <a class="link" href="_io_service.html#boost_asio.reference.io_service._io_service.remarks">Remarks</a> |
| </h6> |
| <p> |
| The destruction sequence described above permits programs to simplify their |
| resource management by using <code class="computeroutput"><span class="identifier">shared_ptr</span><span class="special"><></span></code>. Where an object's lifetime is |
| tied to the lifetime of a connection (or some other sequence of asynchronous |
| operations), a <code class="computeroutput"><span class="identifier">shared_ptr</span></code> |
| to the object would be bound into the handlers for all asynchronous operations |
| associated with it. This works as follows: |
| </p> |
| <div class="itemizedlist"><ul class="itemizedlist" type="disc"> |
| <li class="listitem"> |
| When a single connection ends, all associated asynchronous operations |
| complete. The corresponding handler objects are destroyed, and all |
| <code class="computeroutput"><span class="identifier">shared_ptr</span></code> references |
| to the objects are destroyed. |
| </li> |
| <li class="listitem"> |
| To shut down the whole program, the <a class="link" href="../io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a> function <code class="computeroutput"><span class="identifier">stop</span><span class="special">()</span></code> |
| is called to terminate any <code class="computeroutput"><span class="identifier">run</span><span class="special">()</span></code> calls as soon as possible. The <a class="link" href="../io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a> |
| destructor defined above destroys all handlers, causing all <code class="computeroutput"><span class="identifier">shared_ptr</span></code> references to all connection |
| objects to be destroyed. |
| </li> |
| </ul></div> |
| </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 - 2010 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="wrap.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../io_service.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="../io_service__id.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| </body> |
| </html> |