1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Wait traits requirements</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="WaitHandler.html" title="Wait handler requirements"> 10<link rel="next" href="WriteHandler.html" title="Write 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="WaitHandler.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="WriteHandler.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.WaitTraits"></a><a class="link" href="WaitTraits.html" title="Wait traits requirements">Wait traits requirements</a> 28</h3></div></div></div> 29<p> 30 The <code class="computeroutput">basic_waitable_timer</code> template uses wait traits to allow 31 programs to customize <code class="computeroutput">wait</code> and <code class="computeroutput">async_wait</code> behavior. 32 [<span class="emphasis"><em>Note:</em></span> Possible uses of wait traits include:<br> — To 33 enable timers based on non-realtime clocks.<br> — Determining how quickly 34 wallclock-based timers respond to system time changes.<br> — Correcting for 35 errors or rounding timeouts to boundaries.<br> — Preventing duration overflow. 36 That is, a program may set a timer's expiry <code class="computeroutput">e</code> to be <code class="computeroutput">Clock::max()</code> 37 (meaning never reached) or <code class="computeroutput">Clock::min()</code> (meaning always in the 38 past). As a result, computing the duration until timer expiry as <code class="computeroutput">e 39 - Clock::now()</code> may cause overflow. —<span class="emphasis"><em>end note</em></span>] 40 </p> 41<p> 42 For a type <code class="computeroutput">Clock</code> meeting the <code class="computeroutput">Clock</code> requirements 43 (C++Std [time.clock.req]), a type <code class="computeroutput">X</code> meets the <code class="computeroutput">WaitTraits</code> 44 requirements if it satisfies the requirements listed below. 45 </p> 46<p> 47 In the table below, <code class="computeroutput">t</code> denotes a (possibly const) value of type 48 <code class="computeroutput">Clock::time_point</code>; and <code class="computeroutput">d</code> denotes a (possibly const) 49 value of type <code class="computeroutput">Clock::duration</code>. 50 </p> 51<div class="table"> 52<a name="boost_asio.reference.WaitTraits.t0"></a><p class="title"><b>Table 33. WaitTraits requirements</b></p> 53<div class="table-contents"><table class="table" summary="WaitTraits requirements"> 54<colgroup> 55<col> 56<col> 57<col> 58</colgroup> 59<thead><tr> 60<th> 61 <p> 62 expression 63 </p> 64 </th> 65<th> 66 <p> 67 return type 68 </p> 69 </th> 70<th> 71 <p> 72 assertion/note<br> pre/post-condition 73 </p> 74 </th> 75</tr></thead> 76<tbody> 77<tr> 78<td> 79 <p> 80 <code class="computeroutput">X::to_wait_duration(d)</code> 81 </p> 82 </td> 83<td> 84 <p> 85 <code class="computeroutput">Clock::duration</code> 86 </p> 87 </td> 88<td> 89 <p> 90 Returns a <code class="computeroutput">Clock::duration</code> value to be used in a <code class="computeroutput">wait</code> 91 or <code class="computeroutput">async_wait</code> operation. [<span class="emphasis"><em>Note:</em></span> 92 The return value is typically representative of the duration <code class="computeroutput">d</code>. 93 —<span class="emphasis"><em>end note</em></span>] 94 </p> 95 </td> 96</tr> 97<tr> 98<td> 99 <p> 100 <code class="computeroutput">X::to_wait_duration(t)</code> 101 </p> 102 </td> 103<td> 104 <p> 105 <code class="computeroutput">Clock::duration</code> 106 </p> 107 </td> 108<td> 109 <p> 110 Returns a <code class="computeroutput">Clock::duration</code> value to be used in a <code class="computeroutput">wait</code> 111 or <code class="computeroutput">async_wait</code> operation. [<span class="emphasis"><em>Note:</em></span> 112 The return value is typically representative of the duration from 113 <code class="computeroutput">Clock::now()</code> until the time point <code class="computeroutput">t</code>. 114 —<span class="emphasis"><em>end note</em></span>] 115 </p> 116 </td> 117</tr> 118</tbody> 119</table></div> 120</div> 121<br class="table-break"> 122</div> 123<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 124<td align="left"></td> 125<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 126 Kohlhoff<p> 127 Distributed under the Boost Software License, Version 1.0. (See accompanying 128 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>) 129 </p> 130</div></td> 131</tr></table> 132<hr> 133<div class="spirit-nav"> 134<a accesskey="p" href="WaitHandler.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="WriteHandler.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 135</div> 136</body> 137</html> 138