Imported Upstream version 1.72.0
[platform/upstream/boost.git] / doc / html / boost_asio / reference / post / overload2.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>post (2 of 3 overloads)</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="../post.html" title="post">
9 <link rel="prev" href="overload1.html" title="post (1 of 3 overloads)">
10 <link rel="next" href="overload3.html" title="post (3 of 3 overloads)">
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="overload1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../post.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="overload3.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.post.overload2"></a><a class="link" href="overload2.html" title="post (2 of 3 overloads)">post (2 of 3 overloads)</a>
28 </h4></div></div></div>
29 <p>
30           Submits a completion token or function object for execution.
31         </p>
32 <pre class="programlisting">template&lt;
33     typename <a class="link" href="../Executor1.html" title="Executor requirements">Executor</a>,
34     typename CompletionToken = <a class="link" href="../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.default_completion_tokens"><span class="emphasis"><em>DEFAULT</em></span></a>&gt;
35 <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(
36     const Executor &amp; ex,
37     CompletionToken &amp;&amp; token = <a class="link" href="../asynchronous_operations.html#boost_asio.reference.asynchronous_operations.default_completion_tokens"><span class="emphasis"><em>DEFAULT</em></span></a>,
38     typename enable_if&lt; is_executor&lt; Executor &gt;::value &gt;::type *  = 0);
39 </pre>
40 <p>
41           This function submits an object for execution using the specified executor.
42           The function object is queued for execution, and is never called from the
43           current thread prior to returning from <code class="computeroutput">post()</code>.
44         </p>
45 <p>
46           The use of <code class="computeroutput">post()</code>, rather than <a class="link" href="../defer.html" title="defer"><code class="computeroutput">defer</code></a>
47           , indicates the caller's preference that the function object be eagerly
48           queued for execution.
49         </p>
50 <p>
51           This function has the following effects:
52         </p>
53 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
54 <li class="listitem">
55               Constructs a function object handler of type <code class="computeroutput">Handler</code>,
56               initialized with <code class="computeroutput">handler(forward&lt;CompletionToken&gt;(token))</code>.
57             </li>
58 <li class="listitem">
59               Constructs an object <code class="computeroutput">result</code> of type <code class="computeroutput">async_result&lt;Handler&gt;</code>,
60               initializing the object as <code class="computeroutput">result(handler)</code>.
61             </li>
62 <li class="listitem">
63               Obtains the handler's associated executor object <code class="computeroutput">ex1</code> by
64               performing <code class="computeroutput">get_associated_executor(handler)</code>.
65             </li>
66 <li class="listitem">
67               Creates a work object <code class="computeroutput">w</code> by performing <code class="computeroutput">make_work(ex1)</code>.
68             </li>
69 <li class="listitem">
70               Obtains the handler's associated allocator object <code class="computeroutput">alloc</code>
71               by performing <code class="computeroutput">get_associated_allocator(handler)</code>.
72             </li>
73 <li class="listitem">
74               Constructs a function object <code class="computeroutput">f</code> with a function call operator
75               that performs <code class="computeroutput">ex1.dispatch(std::move(handler), alloc)</code>
76               followed by <code class="computeroutput">w.reset()</code>.
77             </li>
78 <li class="listitem">
79               Performs <code class="computeroutput">Executor(ex).post(std::move(f), alloc)</code>.
80             </li>
81 <li class="listitem">
82               Returns <code class="computeroutput">result.get()</code>.
83             </li>
84 </ul></div>
85 </div>
86 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
87 <td align="left"></td>
88 <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2019 Christopher M. Kohlhoff<p>
89         Distributed under the Boost Software License, Version 1.0. (See accompanying
90         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>)
91       </p>
92 </div></td>
93 </tr></table>
94 <hr>
95 <div class="spirit-nav">
96 <a accesskey="p" href="overload1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../post.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="overload3.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
97 </div>
98 </body>
99 </html>