fibers.qbk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. [/
  2. Copyright Oliver Kowalke 2013.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt
  6. ]
  7. [library Fiber
  8. [quickbook 1.5]
  9. [authors [Kowalke, Oliver]]
  10. [copyright 2013 Oliver Kowalke]
  11. [id fiber]
  12. [purpose C++ Library to cooperatively schedule and synchronize micro-threads]
  13. [category text]
  14. [license
  15. Distributed under the Boost Software License, Version 1.0.
  16. (See accompanying file LICENSE_1_0.txt or copy at
  17. [@http://www.boost.org/LICENSE_1_0.txt])
  18. ]
  19. ]
  20. [/ important especially for [,] to avoid a space between empty argument
  21. brackets and expansion: the space, if any, becomes part of the expansion!]
  22. [template mdash[]'''—''']
  23. [template ,[]'''’''']
  24. [template "[text]'''“'''[text]'''”''']
  25. [template superscript[exp]'''<superscript>'''[exp]'''</superscript>''']
  26. [/ "isn[t]" is slightly more readable than "isn[,]t", and so forth]
  27. [template s[][,]s]
  28. [template t[][,]t]
  29. [template class_heading[class_name]
  30. [hding class_[class_name]..Class [`[class_name]]]
  31. ]
  32. [template class_link[class_name][dblink class_[class_name]..[`[class_name]]]]
  33. [template template_heading[class_name]
  34. [hding class_[class_name]..Template [`[class_name]<>]]
  35. ]
  36. [template template_link[class_name][dblink class_[class_name]..[`[class_name]<>]]]
  37. [template member_heading[class_name method_name]
  38. [operator_heading [class_name]..[method_name]..[method_name]]
  39. ]
  40. [template member_link[class_name method_name][operator_link [class_name]..[method_name]..[method_name]]]
  41. [template operator_heading[class_name method_name method_text]
  42. [hding [class_name]_[method_name]..Member function [`[method_text]]()]
  43. ]
  44. [template operator_link[class_name method_name method_text][dblink [class_name]_[method_name]..[`[class_name]::[method_text]()]]]
  45. [template template_member_heading[class_name method_name]
  46. [hding [class_name]_[method_name]..Templated member function [`[method_name]]()]
  47. ]
  48. [template template_member_link[class_name method_name][member_link [class_name]..[method_name]]]
  49. [template static_member_heading[class_name method_name]
  50. [hding [class_name]_[method_name]..Static member function [`[method_name]]()]
  51. ]
  52. [template static_member_link[class_name method_name][member_link [class_name]..[method_name]]]
  53. [template data_member_heading[class_name member_name]
  54. [hding [class_name]_[member_name]..Data member [`[member_name]]]
  55. ]
  56. [template data_member_link[class_name member_name][dblink [class_name]_[member_name]..[`[class_name]::[member_name]]]]
  57. [template function_heading[function_name]
  58. [hding [function_name]..Non-member function [`[function_name]()]]
  59. ]
  60. [template function_link[function_name][dblink [function_name]..[`[function_name]()]]]
  61. [template function_heading_for[function_name arg]
  62. [hding [function_name]\_for\_[arg]..Non-member function [`[function_name]()]]
  63. ]
  64. [template function_link_for[function_name arg][dblink [function_name]\_for\_[arg]..[`[function_name]()]]]
  65. [template ns_class_heading[namespace class_name]
  66. [hding class_[namespace]_[class_name]..Class [`[namespace]::[class_name]]]
  67. ]
  68. [template ns_class_link[namespace class_name][dblink class_[namespace]_[class_name]..[`[namespace]::[class_name]]]]
  69. [template ns_member_heading[namespace class_name method_name]
  70. [ns_operator_heading [namespace]..[class_name]..[method_name]..[method_name]]
  71. ]
  72. [template ns_member_link[namespace class_name method_name][ns_operator_link [namespace]..[class_name]..[method_name]..[method_name]]]
  73. [template ns_operator_heading[namespace class_name method_name method_text]
  74. [hding [namespace]_[class_name]_[method_name]..Member function [`[method_text]]()]
  75. ]
  76. [template ns_operator_link[namespace class_name method_name method_text][dblink [namespace]_[class_name]_[method_name]..[`[namespace]::[class_name]::[method_text]()]]]
  77. [template ns_data_member_heading[namespace class_name member_name]
  78. [hding [namespace]_[class_name]_[member_name]..Data member [`[member_name]]]
  79. ]
  80. [template ns_data_member_link[namespace class_name member_name][dblink [namespace]_[class_name]_[member_name]..[`[namespace]::[class_name]::[member_name]]]]
  81. [template ns_function_heading[namespace function_name]
  82. [hding [namespace]_[function_name]..Non-member function [`[namespace]::[function_name]()]]
  83. ]
  84. [template ns_function_link[namespace function_name][dblink [namespace]_[function_name]..[`[namespace]::[function_name]()]]]
  85. [template anchor[name]'''<anchor id="'''[name]'''"/>''']
  86. [template hding[name title]
  87. '''<bridgehead renderas="sect4" id="'''[name]_bridgehead'''">
  88. <phrase id="'''[name]'''"/>
  89. <link linkend="'''[name]'''">'''[title]'''</link>
  90. </bridgehead>'''
  91. ]
  92. [template dblink[id text]'''<link linkend="'''[id]'''">'''[text]'''</link>''']
  93. [template `[text]'''<code>'''[text]'''</code>''']
  94. [def __boost_asio__ [@http://www.boost.org/doc/libs/release/libs/asio/index.html Boost.Asio]]
  95. [def __boost_context__ [@http://www.boost.org/doc/libs/release/libs/context/index.html Boost.Context]]
  96. [def __boost_fiber__ [*Boost.Fiber]]
  97. [def __boost_intrusive__ [@http://www.boost.org/doc/libs/release/libs/intrusive/index.html Boost.Intrusive]]
  98. [def __boost_thread__ [@http://www.boost.org/doc/libs/release/libs/thread/index.html Boost.Thread]]
  99. [def __std_thread__ [@http://en.cppreference.com/w/cpp/thread standard thread support library]]
  100. [def __async_result__ ['async-result]]
  101. [def __blocked__ [link blocking ['blocked]]]
  102. [def __lockable_concept__ ['lockable concept]]
  103. [def __not_a_fiber__ ['not-a-fiber]]
  104. [def __rendezvous__ ['rendezvous]]
  105. [def __allocator_arg_t__ [@http://en.cppreference.com/w/cpp/memory/allocator_arg_t `std::allocator_arg_t`]]
  106. [def __Allocator__ [@http://en.cppreference.com/w/cpp/concept/Allocator `Allocator`]]
  107. [def __allocator__ [@http://en.cppreference.com/w/cpp/memory/allocator `std::allocator< T >`]]
  108. [def __barrier__ [class_link barrier]]
  109. [def __cc__ [@http://www.boost.org/doc/libs/release/libs/context/doc/html/context/cc.html ['call/cc]]]
  110. [def __condition__ [class_link condition_variable]]
  111. [def __fcontext__ `fcontext_t`]
  112. [def __fiber__ [class_link fiber]]
  113. [def __fiber_error__ `fiber_error`]
  114. [def __fiber_error__ `fiber_error`]
  115. [def __fiber_group__ [class_link fiber_group]]
  116. [def __fibers__ `fibers`]
  117. [def __fixedsize_stack__ [class_link fixedsize_stack]]
  118. [def __future_error__ `future_error`]
  119. [def __future__ [template_link future]]
  120. [def __joinable__ [member_link fiber..joinable]]
  121. [def __lock_error__ `lock_error`]
  122. [def __mutex__ [class_link mutex]]
  123. [def __numa_work_stealing__ [ns_class_link numa..work_stealing]]
  124. [def __ofixedsize_stack__ [class_link pooled_fixedsize_stack]]
  125. [def __packaged_task__ [template_link packaged_task]]
  126. [def __pfixedsize_stack__ [class_link protected_fixedsize_stack]]
  127. [def __promise__ [template_link promise]]
  128. [def __recursive_mutex__ [class_link recursive_mutex]]
  129. [def __recursive_timed_mutex__ [class_link recursive_timed_mutex]]
  130. [def __round_robin__ [class_link round_robin]]
  131. [def __segmented_stack__ [class_link segmented_stack]]
  132. [def __segmented_stack_stack__ ['segmented_stack-stack]]
  133. [def __shared_future__ [template_link shared_future]]
  134. [def __shared_work__ [class_link shared_work]]
  135. [def __stack_allocator_concept__ [link stack_allocator_concept ['stack-allocator concept]]]
  136. [def __StackAllocator__ [link stack_allocator_concept `StackAllocator`]]
  137. [def __stack_allocator__ ['stack_allocator]]
  138. [def __stack_context__ [@http://www.boost.org/doc/libs/release/libs/context/doc/html/context/stack/stack_context.html `stack_context`]]
  139. [def __timed_mutex__ [class_link timed_mutex]]
  140. [def __ucontext__ `ucontext_t`]
  141. [def __unique_lock__ [@http://en.cppreference.com/w/cpp/thread/unique_lock `std::unique_lock`]]
  142. [def __wait_for__ [member_link future..wait_for]]
  143. [def __wait__ [member_link future..wait]]
  144. [def __wait_until__ [member_link future..wait_until]]
  145. [def __winfib__ `WinFiber`]
  146. [def __work_stealing__ [class_link work_stealing]]
  147. [def __no_state__ `future_errc::no_state`]
  148. [def __broken_promise__ `future_errc::broken_promise`]
  149. [def __already_retrieved__ `future_errc::future_already_retrieved`]
  150. [def __already_satisfied__ `future_errc::future_already_satisfied`]
  151. [def __algo__ [class_link algorithm]]
  152. [def __algo_awakened__ [member_link algorithm..awakened]]
  153. [def __algo_pick_next__ [member_link algorithm..pick_next]]
  154. [def __async__ `async()`]
  155. [def __barrier_wait__ [member_link barrier..wait]]
  156. [def __cond_wait_for__ [member_link condition_variable..wait_for]]
  157. [def __cond_wait__ [member_link condition_variable..wait]]
  158. [def __cond_wait_until__ [member_link condition_variable..wait_until]]
  159. [def __cond_any_wait_for__ [member_link condition_variable_any..wait_for]]
  160. [def __cond_any_wait__ [member_link condition_variable_any..wait]]
  161. [def __cond_any_wait_until__ [member_link condition_variable_any..wait_until]]
  162. [def __context_attach__ [member_link context..attach]]
  163. [def __context_detach__ [member_link context..detach]]
  164. [def __detach__ [member_link fiber..detach]]
  165. [def __fiber_id__ [dblink class_fiber_id..`fiber::id`]]
  166. [def __fsp__ [class_link fiber_specific_ptr]]
  167. [def __future_get__ [member_link future..get]]
  168. [def __get_id__ [member_link fiber..get_id]]
  169. [def __io_service__ [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/io_service.html `boost::asio::io_service`]]
  170. [def __join__ [member_link fiber..join]]
  171. [def __mutex_lock__ [member_link mutex..lock]]
  172. [def __mutex_try_lock__ [member_link mutex..try_lock]]
  173. [def __run_service__ `boost::fibers::asio::run_svc()`]
  174. [def __shared_future_get__ [member_link shared_future..get]]
  175. [def __sleep_for__ [ns_function_link this_fiber..sleep_for]]
  176. [def __sleep_until__ [ns_function_link this_fiber..sleep_until]]
  177. [def __yield_context__ ['boost::asio::yield_context]]
  178. [def __yield_fiber__ ['boost::fibers::asio::yield_context]]
  179. [def __yield__ [ns_function_link this_fiber..yield]]
  180. [def __lock__ `lock()`]
  181. [def __try_lock_for__ `try_lock_for()`]
  182. [def __try_lock__ `try_lock()`]
  183. [def __try_lock_until__ `try_lock_until()`]
  184. [def __unlock__ `unlock()`]
  185. [include overview.qbk]
  186. [include fiber.qbk]
  187. [include scheduling.qbk]
  188. [include stack.qbk]
  189. [#synchronization]
  190. [section:synchronization Synchronization]
  191. In general, __boost_fiber__ synchronization objects can neither be moved nor
  192. copied. A synchronization object acts as a mutually-agreed rendezvous point
  193. between different fibers. If such an object were copied somewhere else, the
  194. new copy would have no consumers. If such an object were ['moved] somewhere
  195. else, leaving the original instance in an unspecified state, existing
  196. consumers would behave strangely.
  197. The fiber synchronization objects provided by this library will, by default,
  198. safely synchronize fibers running on different threads. However, this level of
  199. synchronization can be removed (for performance) by building the library with
  200. [*`BOOST_FIBERS_NO_ATOMICS`] defined. When the library is built with that macro,
  201. you must ensure that all the fibers referencing a particular synchronization
  202. object are running in the same thread.
  203. [include mutexes.qbk]
  204. [include condition_variables.qbk]
  205. [include barrier.qbk]
  206. [section:channels Channels]
  207. A channel is a model to communicate and synchronize `Threads of Execution`
  208. [footnote The smallest ordered sequence of instructions that can be managed
  209. independently by a scheduler is called a `Thread of Execution`.] via message
  210. passing.
  211. [#class_channel_op_status]
  212. [heading Enumeration `channel_op_status`]
  213. channel operations return the state of the channel.
  214. enum class channel_op_status {
  215. success,
  216. empty,
  217. full,
  218. closed,
  219. timeout
  220. };
  221. [heading `success`]
  222. [variablelist
  223. [[Effects:] [Operation was successful.]]
  224. ]
  225. [heading `empty`]
  226. [variablelist
  227. [[Effects:] [channel is empty, operation failed.]]
  228. ]
  229. [heading `full`]
  230. [variablelist
  231. [[Effects:] [channel is full, operation failed.]]
  232. ]
  233. [heading `closed`]
  234. [variablelist
  235. [[Effects:] [channel is closed, operation failed.]]
  236. ]
  237. [heading `timeout`]
  238. [variablelist
  239. [[Effects:] [The operation did not become ready before specified timeout elapsed.]]
  240. ]
  241. [include buffered_channel.qbk]
  242. [include unbuffered_channel.qbk]
  243. [endsect]
  244. [include futures.qbk]
  245. [endsect]
  246. [include fls.qbk]
  247. [/[include asio.qbk]]
  248. [include migration.qbk]
  249. [include callbacks.qbk]
  250. [include nonblocking.qbk]
  251. [include when_any.qbk]
  252. [include integration.qbk]
  253. [include speculative.qbk]
  254. [include numa.qbk]
  255. [section GPU computing]
  256. [include cuda.qbk]
  257. [include hip.qbk]
  258. [endsect]
  259. [include worker.qbk]
  260. [include performance.qbk]
  261. [include tuning.qbk]
  262. [include customization.qbk]
  263. [include rationale.qbk]
  264. [include acknowledgements.qbk]