1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Handlers</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="../reference.html" title="Reference"> 9<link rel="prev" href="GettableSocketOption.html" title="Gettable socket option requirements"> 10<link rel="next" href="HandshakeHandler.html" title="SSL handshake handler requirements"> 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="GettableSocketOption.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="HandshakeHandler.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_asio.reference.Handler"></a><a class="link" href="Handler.html" title="Handlers">Handlers</a> 28</h3></div></div></div> 29<p> 30 A handler must meet the requirements of <code class="computeroutput">MoveConstructible</code> types 31 (C++Std [moveconstructible]). 32 </p> 33<p> 34 In the table below, <code class="computeroutput">X</code> denotes a handler class, <code class="computeroutput">h</code> 35 denotes a value of <code class="computeroutput">X</code>, <code class="computeroutput">p</code> denotes a pointer to a 36 block of allocated memory of type <code class="computeroutput">void*</code>, <code class="computeroutput">s</code> denotes 37 the size for a block of allocated memory, and <code class="computeroutput">f</code> denotes a function 38 object taking no arguments. 39 </p> 40<div class="table"> 41<a name="boost_asio.reference.Handler.t0"></a><p class="title"><b>Table 18. Handler requirements</b></p> 42<div class="table-contents"><table class="table" summary="Handler requirements"> 43<colgroup> 44<col> 45<col> 46<col> 47</colgroup> 48<thead><tr> 49<th> 50 <p> 51 expression 52 </p> 53 </th> 54<th> 55 <p> 56 return type 57 </p> 58 </th> 59<th> 60 <p> 61 assertion/note<br> pre/post-conditions 62 </p> 63 </th> 64</tr></thead> 65<tbody> 66<tr> 67<td> 68 <p> 69</p> 70<pre class="programlisting">using boost::asio::asio_handler_allocate; 71asio_handler_allocate(s, &h); 72</pre> 73<p> 74 </p> 75 </td> 76<td> 77 <p> 78 <code class="computeroutput">void*</code> 79 </p> 80 </td> 81<td> 82 <p> 83 Returns a pointer to a block of memory of size <code class="computeroutput">s</code>. 84 The pointer must satisfy the same alignment requirements as a pointer 85 returned by <code class="computeroutput">::operator new()</code>. Throws <code class="computeroutput">bad_alloc</code> 86 on failure.<br> <br> The <code class="computeroutput">asio_handler_allocate()</code> 87 function is located using argument-dependent lookup. The function 88 <code class="computeroutput">boost::asio::asio_handler_allocate()</code> serves as a default 89 if no user-supplied function is available. 90 </p> 91 </td> 92</tr> 93<tr> 94<td> 95 <p> 96</p> 97<pre class="programlisting">using boost::asio::asio_handler_deallocate; 98asio_handler_deallocate(p, s, &h); 99</pre> 100<p> 101 </p> 102 </td> 103<td> 104 </td> 105<td> 106 <p> 107 Frees a block of memory associated with a pointer <code class="computeroutput">p</code>, 108 of at least size <code class="computeroutput">s</code>, that was previously allocated 109 using <code class="computeroutput">asio_handler_allocate()</code>.<br> <br> The <code class="computeroutput">asio_handler_deallocate()</code> 110 function is located using argument-dependent lookup. The function 111 <code class="computeroutput">boost::asio::asio_handler_deallocate()</code> serves as a 112 default if no user-supplied function is available. 113 </p> 114 </td> 115</tr> 116<tr> 117<td> 118 <p> 119</p> 120<pre class="programlisting">using boost::asio::asio_handler_invoke; 121asio_handler_invoke(f, &h); 122</pre> 123<p> 124 </p> 125 </td> 126<td> 127 </td> 128<td> 129 <p> 130 Causes the function object <code class="computeroutput">f</code> to be executed as if 131 by calling <code class="computeroutput">f()</code>.<br> <br> The <code class="computeroutput">asio_handler_invoke()</code> 132 function is located using argument-dependent lookup. The function 133 <code class="computeroutput">boost::asio::asio_handler_invoke()</code> serves as a default 134 if no user-supplied function is available. 135 </p> 136 </td> 137</tr> 138</tbody> 139</table></div> 140</div> 141<br class="table-break"> 142</div> 143<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 144<td align="left"></td> 145<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 146 Kohlhoff<p> 147 Distributed under the Boost Software License, Version 1.0. (See accompanying 148 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>) 149 </p> 150</div></td> 151</tr></table> 152<hr> 153<div class="spirit-nav"> 154<a accesskey="p" href="GettableSocketOption.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="HandshakeHandler.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 155</div> 156</body> 157</html> 158