1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>io_context::post</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="../io_context.html" title="io_context"> 9<link rel="prev" href="poll_one/overload2.html" title="io_context::poll_one (2 of 2 overloads)"> 10<link rel="next" href="reset.html" title="io_context::reset"> 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="poll_one/overload2.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../io_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="reset.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.io_context.post"></a><a class="link" href="post.html" title="io_context::post">io_context::post</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="boost_asio.indexterm.io_context.post"></a> 31(Deprecated: Use <a class="link" href="../post.html" title="post"><code class="computeroutput">post</code></a>.) Request 32 the <a class="link" href="../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 33 to invoke the given handler and return immediately. 34 </p> 35<pre class="programlisting">template< 36 typename <a class="link" href="../LegacyCompletionHandler.html" title="Legacy completion handler requirements">LegacyCompletionHandler</a>> 37<a class="link" href="../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.automatic_deduction_of_initiating_function_return_type"><span class="emphasis"><em>DEDUCED</em></span></a> post( 38 LegacyCompletionHandler && handler); 39</pre> 40<p> 41 This function is used to ask the <a class="link" href="../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 42 to execute the given handler, but without allowing the <a class="link" href="../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 43 to call the handler from inside this function. 44 </p> 45<p> 46 The <a class="link" href="../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 47 guarantees that the handler will only be called in a thread in which the 48 <code class="computeroutput">run()</code>, <code class="computeroutput">run_one()</code>, <code class="computeroutput">poll()</code> or <code class="computeroutput">poll_one()</code> 49 member functions is currently being invoked. 50 </p> 51<h6> 52<a name="boost_asio.reference.io_context.post.h0"></a> 53 <span class="phrase"><a name="boost_asio.reference.io_context.post.parameters"></a></span><a class="link" href="post.html#boost_asio.reference.io_context.post.parameters">Parameters</a> 54 </h6> 55<div class="variablelist"> 56<p class="title"><b></b></p> 57<dl class="variablelist"> 58<dt><span class="term">handler</span></dt> 59<dd> 60<p> 61 The handler to be called. The <a class="link" href="../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> 62 will make a copy of the handler object as required. The function 63 signature of the handler must be: 64</p> 65<pre class="programlisting">void handler(); 66</pre> 67<p> 68 </p> 69</dd> 70</dl> 71</div> 72<h6> 73<a name="boost_asio.reference.io_context.post.h1"></a> 74 <span class="phrase"><a name="boost_asio.reference.io_context.post.remarks"></a></span><a class="link" href="post.html#boost_asio.reference.io_context.post.remarks">Remarks</a> 75 </h6> 76<p> 77 This function throws an exception only if: 78 </p> 79<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 80<li class="listitem"> 81 the handler's <code class="computeroutput">asio_handler_allocate</code> function; or 82 </li> 83<li class="listitem"> 84 the handler's copy constructor 85 </li> 86</ul></div> 87<p> 88 throws an exception. 89 </p> 90</div> 91<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 92<td align="left"></td> 93<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 94 Kohlhoff<p> 95 Distributed under the Boost Software License, Version 1.0. (See accompanying 96 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>) 97 </p> 98</div></td> 99</tr></table> 100<hr> 101<div class="spirit-nav"> 102<a accesskey="p" href="poll_one/overload2.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../io_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="reset.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 103</div> 104</body> 105</html> 106