Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-release > by-pkgid > 2deed065cd3adb9905decb703c6b0100 > files > 307

asio-1.4.5-1.mga1.i586.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>asio_handler_invoke</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="../../index.html" title="Asio">
<link rel="up" href="../reference.html" title="Reference">
<link rel="prev" href="asio_handler_deallocate.html" title="asio_handler_deallocate">
<link rel="next" href="async_read.html" title="async_read">
</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="asio_handler_deallocate.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="async_read.html"><img src="../../next.png" alt="Next"></a>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="asio.reference.asio_handler_invoke"></a><a class="link" href="asio_handler_invoke.html" title="asio_handler_invoke"> asio_handler_invoke</a>
</h3></div></div></div>
<p>
        <a class="indexterm" name="id578223"></a> 
Default invoke function for handlers.
      </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">typename</span> <span class="identifier">Function</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">asio_handler_invoke</span><span class="special">(</span>
    <span class="identifier">Function</span> <span class="identifier">function</span><span class="special">,</span>
    <span class="special">...</span> <span class="special">);</span>
</pre>
<p>
        Completion handlers for asynchronous operations are invoked by the <a class="link" href="io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a>
        associated with the corresponding object (e.g. a socket or deadline_timer).
        Certain guarantees are made on when the handler may be invoked, in particular
        that a handler can only be invoked from a thread that is currently calling
        <code class="computeroutput"><span class="identifier">run</span><span class="special">()</span></code>
        on the corresponding <a class="link" href="io_service.html" title="io_service"><code class="computeroutput"><span class="identifier">io_service</span></code></a> object. Handlers may
        subsequently be invoked through other objects (such as <a class="link" href="io_service__strand.html" title="io_service::strand"><code class="computeroutput"><span class="identifier">io_service</span><span class="special">::</span><span class="identifier">strand</span></code></a> objects) that provide additional
        guarantees.
      </p>
<p>
        When asynchronous operations are composed from other asynchronous operations,
        all intermediate handlers should be invoked using the same method as the
        final handler. This is required to ensure that user-defined objects are not
        accessed in a way that may violate the guarantees. This hooking function
        ensures that the invoked method used for the final handler is accessible
        at each intermediate step.
      </p>
<p>
        Implement asio_handler_invoke for your own handlers to specify a custom invocation
        strategy.
      </p>
<p>
        This default implementation is simply:
      </p>
<pre class="programlisting"><span class="identifier">function</span><span class="special">();</span>
</pre>
<a name="asio.reference.asio_handler_invoke.example"></a><h5>
<a name="id578420"></a>
        <a class="link" href="asio_handler_invoke.html#asio.reference.asio_handler_invoke.example">Example</a>
      </h5>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">my_handler</span><span class="special">;</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Function</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">asio_handler_invoke</span><span class="special">(</span><span class="identifier">Function</span> <span class="identifier">function</span><span class="special">,</span> <span class="identifier">my_handler</span><span class="special">*</span> <span class="identifier">context</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">context</span><span class="special">-&gt;</span><span class="identifier">strand_</span><span class="special">.</span><span class="identifier">dispatch</span><span class="special">(</span><span class="identifier">function</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<a name="asio.reference.asio_handler_invoke.requirements"></a><h5>
<a name="id578586"></a>
        <a class="link" href="asio_handler_invoke.html#asio.reference.asio_handler_invoke.requirements">Requirements</a>
      </h5>
<p>
        <span class="bold"><strong>Header: </strong></span><code class="literal">asio/handler_invoke_hook.hpp</code>
      </p>
<p>
        <span class="bold"><strong>Convenience header: </strong></span><code class="literal">asio.hpp</code>
      </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 &#169; 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="asio_handler_deallocate.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="async_read.html"><img src="../../next.png" alt="Next"></a>
</div>
</body>
</html>