2_streams.qbk 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. [/
  2. Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. Official repository: https://github.com/boostorg/beast
  6. ]
  7. [section:stream_types Streams]
  8. A __Stream__ is a communication channel where data is reliably transferred as
  9. an ordered sequence of bytes. Streams are either synchronous or asynchronous,
  10. and may allow reading, writing, or both. Note that a particular type may model
  11. more than one concept. For example, the networking types __socket__ and
  12. __ssl_stream__ support both __SyncStream__ and __AsyncStream__. All stream
  13. algorithms in Beast are declared as template functions using these concepts:
  14. [table Stream Concepts
  15. [[Concept][Description]]
  16. [
  17. [__SyncReadStream__]
  18. [
  19. Supports buffer-oriented blocking reads.
  20. ]
  21. ][
  22. [__SyncWriteStream__]
  23. [
  24. Supports buffer-oriented blocking writes.
  25. ]
  26. ][
  27. [__SyncStream__]
  28. [
  29. A stream supporting buffer-oriented blocking reads and writes.
  30. ]
  31. ][
  32. [__AsyncReadStream__]
  33. [
  34. Supports buffer-oriented asynchronous reads.
  35. ]
  36. ][
  37. [__AsyncWriteStream__]
  38. [
  39. Supports buffer-oriented asynchronous writes.
  40. ]
  41. ][
  42. [__AsyncStream__]
  43. [
  44. A stream supporting buffer-oriented asynchronous reads and writes.
  45. ]
  46. ]
  47. ]
  48. These template metafunctions check whether a given type meets the
  49. requirements for the various stream concepts, and some additional
  50. useful utilities. The library uses these type checks internally
  51. and also provides them as public interfaces so users may use the
  52. same techniques to augment their own code. The use of these type
  53. checks helps provide more concise errors during compilation:
  54. [table Type Traits and Metafunctions
  55. [[Name][Description]]
  56. [[
  57. [link beast.ref.boost__beast__executor_type `executor_type`]
  58. ][
  59. An alias for the type of object returned by `get_executor`.
  60. ]]
  61. [[
  62. [link beast.ref.boost__beast__has_get_executor `has_get_executor`]
  63. ][
  64. Determine if the `get_executor` member function is present.
  65. ]]
  66. [[
  67. [link beast.ref.boost__beast__is_async_read_stream `is_async_read_stream`]
  68. ][
  69. Determine if a type meets the requirements of __AsyncReadStream__.
  70. ]]
  71. [[
  72. [link beast.ref.boost__beast__is_async_stream `is_async_stream`]
  73. ][
  74. Determine if a type meets the requirements of both __AsyncReadStream__
  75. and __AsyncWriteStream__.
  76. ]]
  77. [[
  78. [link beast.ref.boost__beast__is_async_write_stream `is_async_write_stream`]
  79. ][
  80. Determine if a type meets the requirements of __AsyncWriteStream__.
  81. ]]
  82. [[
  83. [link beast.ref.boost__beast__is_sync_read_stream `is_sync_read_stream`]
  84. ][
  85. Determine if a type meets the requirements of __SyncReadStream__.
  86. ]]
  87. [[
  88. [link beast.ref.boost__beast__is_sync_stream `is_sync_stream`]
  89. ][
  90. Determine if a type meets the requirements of both __SyncReadStream__
  91. and __SyncWriteStream__.
  92. ]]
  93. [[
  94. [link beast.ref.boost__beast__is_sync_write_stream `is_sync_write_stream`]
  95. ][
  96. Determine if a type meets the requirements of __SyncWriteStream__.
  97. ]]
  98. ]
  99. Using the type checks with `static_assert` on function or class template
  100. types will provide users with helpful error messages and prevent undefined
  101. behaviors. This example shows how a template function which writes to a
  102. synchronous stream may check its argument:
  103. [snippet_core_3]
  104. [endsect]