WaitTraits.qbk 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. [/
  2. / Copyright (c) 2003-2019 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. [section:WaitTraits Wait traits requirements]
  8. The `basic_waitable_timer` template uses wait traits to allow programs to
  9. customize `wait` and `async_wait` behavior.
  10. [inline_note Possible uses of wait traits include:\n
  11. [mdash] To enable timers based on non-realtime clocks.\n
  12. [mdash] Determining how quickly wallclock-based timers respond to system time
  13. changes.\n
  14. [mdash] Correcting for errors or rounding timeouts to boundaries.\n
  15. [mdash] Preventing duration overflow. That is, a program may set a timer's
  16. expiry `e` to be `Clock::max()` (meaning never reached) or `Clock::min()`
  17. (meaning always in the past). As a result, computing the duration until timer
  18. expiry as `e - Clock::now()` may cause overflow.]
  19. For a type `Clock` meeting the `Clock` requirements (C++Std
  20. [time.clock.req]), a type `X` meets the `WaitTraits` requirements if it
  21. satisfies the requirements listed below.
  22. In the table below, `t` denotes a (possibly const) value of type
  23. `Clock::time_point`; and `d` denotes a (possibly const) value of type
  24. `Clock::duration`.
  25. [table WaitTraits requirements
  26. [[expression] [return type] [assertion/note\npre/post-condition]]
  27. [
  28. [`X::to_wait_duration(d)`]
  29. [`Clock::duration`]
  30. [
  31. Returns a `Clock::duration` value to be used in a `wait` or `async_wait`
  32. operation. [inline_note The return value is typically representative of
  33. the duration `d`.]
  34. ]
  35. ]
  36. [
  37. [`X::to_wait_duration(t)`]
  38. [`Clock::duration`]
  39. [
  40. Returns a `Clock::duration` value to be used in a `wait` or `async_wait`
  41. operation. [inline_note The return value is typically representative of
  42. the duration from `Clock::now()` until the time point `t`.]
  43. ]
  44. ]
  45. ]
  46. [endsect]