1[/ 2 / Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 3 / 4 / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 /] 7 8[section:WaitTraits Wait traits requirements] 9 10The `basic_waitable_timer` template uses wait traits to allow programs to 11customize `wait` and `async_wait` behavior. 12[inline_note Possible uses of wait traits include:[br] 13[mdash] To enable timers based on non-realtime clocks.[br] 14[mdash] Determining how quickly wallclock-based timers respond to system time 15changes.[br] 16[mdash] Correcting for errors or rounding timeouts to boundaries.[br] 17[mdash] Preventing duration overflow. That is, a program may set a timer's 18expiry `e` to be `Clock::max()` (meaning never reached) or `Clock::min()` 19(meaning always in the past). As a result, computing the duration until timer 20expiry as `e - Clock::now()` may cause overflow.] 21 22For a type `Clock` meeting the `Clock` requirements (C++Std 23[time.clock.req]), a type `X` meets the `WaitTraits` requirements if it 24satisfies the requirements listed below. 25 26In the table below, `t` denotes a (possibly const) value of type 27`Clock::time_point`; and `d` denotes a (possibly const) value of type 28`Clock::duration`. 29 30[table WaitTraits requirements 31 [[expression] [return type] [assertion/note[br]pre/post-condition]] 32 [ 33 [`X::to_wait_duration(d)`] 34 [`Clock::duration`] 35 [ 36 Returns a `Clock::duration` value to be used in a `wait` or `async_wait` 37 operation. [inline_note The return value is typically representative of 38 the duration `d`.] 39 ] 40 ] 41 [ 42 [`X::to_wait_duration(t)`] 43 [`Clock::duration`] 44 [ 45 Returns a `Clock::duration` value to be used in a `wait` or `async_wait` 46 operation. [inline_note The return value is typically representative of 47 the duration from `Clock::now()` until the time point `t`.] 48 ] 49 ] 50] 51 52[endsect] 53