autodoc.xml 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <?xml version="1.0" standalone="yes"?>
  2. <library-reference><header name="boost/lockfree/lockfree_forward.hpp">
  3. </header>
  4. <header name="boost/lockfree/policies.hpp">
  5. <namespace name="boost">
  6. <namespace name="lockfree">
  7. <struct name="allocator"><template>
  8. <template-type-parameter name="Alloc"/>
  9. </template><inherit access="public">boost::parameter::template_keyword&lt; tag::allocator, Alloc &gt;</inherit><description><para>Defines the <emphasis role="bold">allocator</emphasis> type of a data structure. </para></description></struct><struct name="capacity"><template>
  10. <template-nontype-parameter name="Size"><type>size_t</type></template-nontype-parameter>
  11. </template><inherit access="public">boost::parameter::template_keyword&lt; tag::capacity, boost::mpl::size_t&lt; Size &gt; &gt;</inherit><description><para>Sets the <emphasis role="bold">capacity</emphasis> of a data structure at compile-time.</para><para>This implies that a data structure is bounded and fixed-sized. </para></description></struct><struct name="fixed_sized"><template>
  12. <template-nontype-parameter name="IsFixedSized"><type>bool</type></template-nontype-parameter>
  13. </template><inherit access="public">boost::parameter::template_keyword&lt; tag::fixed_sized, boost::mpl::bool_&lt; IsFixedSized &gt; &gt;</inherit><description><para>Configures a data structure as <emphasis role="bold">fixed-sized</emphasis>.</para><para>The internal nodes are stored inside an array and they are addressed by array indexing. This limits the possible size of the queue to the number of elements that can be addressed by the index type (usually 2**16-2), but on platforms that lack double-width compare-and-exchange instructions, this is the best way to achieve lock-freedom. This implies that a data structure is bounded. </para></description></struct></namespace>
  14. </namespace>
  15. </header>
  16. <header name="boost/lockfree/queue.hpp">
  17. <namespace name="boost">
  18. <namespace name="lockfree">
  19. <class name="queue"><template>
  20. <template-type-parameter name="T"/>
  21. <template-nontype-parameter name="Options"><type>typename ...</type></template-nontype-parameter>
  22. </template><description><para>The queue class provides a multi-writer/multi-reader queue, pushing and popping is lock-free, construction/destruction has to be synchronized. It uses a freelist for memory management, freed nodes are pushed to the freelist and not returned to the OS before the queue is destroyed.</para><para><emphasis role="bold">Policies:</emphasis> <itemizedlist>
  23. <listitem><para><classname alt="boost::lockfree::fixed_sized">boost::lockfree::fixed_sized</classname>, defaults to <computeroutput>boost::lockfree::fixed_sized&lt;false&gt;</computeroutput> <sbr/>
  24. Can be used to completely disable dynamic memory allocations during push in order to ensure lockfree behavior. <sbr/>
  25. If the data structure is configured as fixed-sized, the internal nodes are stored inside an array and they are addressed by array indexing. This limits the possible size of the queue to the number of elements that can be addressed by the index type (usually 2**16-2), but on platforms that lack double-width compare-and-exchange instructions, this is the best way to achieve lock-freedom.</para>
  26. </listitem><listitem><para><classname alt="boost::lockfree::capacity">boost::lockfree::capacity</classname>, optional <sbr/>
  27. If this template argument is passed to the options, the size of the queue is set at compile-time.<sbr/>
  28. This option implies <computeroutput>fixed_sized&lt;true&gt;</computeroutput> </para>
  29. </listitem><listitem><para><classname alt="boost::lockfree::allocator">boost::lockfree::allocator</classname>, defaults to <computeroutput><classname alt="boost::lockfree::allocator">boost::lockfree::allocator</classname>&lt;std::allocator&lt;void&gt;&gt;</computeroutput> <sbr/>
  30. Specifies the allocator that is used for the internal freelist</para>
  31. </listitem></itemizedlist>
  32. </para><para><emphasis role="bold">Requirements:</emphasis> <itemizedlist>
  33. <listitem><para>T must have a copy constructor</para>
  34. </listitem><listitem><para>T must have a trivial assignment operator</para>
  35. </listitem><listitem><para>T must have a trivial destructor </para>
  36. </listitem></itemizedlist>
  37. </para></description><constructor><parameter name=""><paramtype>void</paramtype></parameter><purpose>Construct queue. </purpose></constructor>
  38. <constructor specifiers="explicit"><template>
  39. <template-type-parameter name="U"/>
  40. </template><parameter name="alloc"><paramtype><emphasis>unspecified</emphasis></paramtype></parameter></constructor>
  41. <constructor specifiers="explicit"><parameter name="alloc"><paramtype>allocator const &amp;</paramtype></parameter></constructor>
  42. <constructor specifiers="explicit"><parameter name="n"><paramtype>size_type</paramtype></parameter><purpose>Construct queue, allocate n nodes for the freelist. </purpose></constructor>
  43. <constructor><template>
  44. <template-type-parameter name="U"/>
  45. </template><parameter name="n"><paramtype>size_type</paramtype></parameter><parameter name="alloc"><paramtype><emphasis>unspecified</emphasis></paramtype></parameter></constructor>
  46. <typedef name="value_type"><type>T</type></typedef>
  47. <typedef name="allocator"><type>implementation_defined::allocator</type></typedef>
  48. <typedef name="size_type"><type>implementation_defined::size_type</type></typedef>
  49. <method-group name="public member functions">
  50. <method name="is_lock_free" cv="const"><type>bool</type><parameter name=""><paramtype>void</paramtype></parameter><description><para>
  51. <warning><para>It only checks, if the queue head and tail nodes and the freelist can be modified in a lock-free manner. On most platforms, the whole implementation is lock-free, if this is true. Using c++0x-style atomics, there is no possibility to provide a completely accurate implementation, because one would need to test every internal node, which is impossible if further nodes will be allocated from the operating system. </para>
  52. </warning>
  53. </para></description><returns><para>true, if implementation is lock-free.</para>
  54. </returns></method>
  55. <method name="reserve"><type>void</type><parameter name="n"><paramtype>size_type</paramtype></parameter></method>
  56. <method name="reserve_unsafe"><type>void</type><parameter name="n"><paramtype>size_type</paramtype></parameter></method>
  57. <method name="empty" cv="const"><type>bool</type><parameter name=""><paramtype>void</paramtype></parameter><description><para>Check if the queue is empty</para><para>
  58. <note><para>The result is only accurate, if no other thread modifies the queue. Therefore it is rarely practical to use this value in program logic. </para>
  59. </note>
  60. </para></description><returns><para>true, if the queue is empty, false otherwise </para>
  61. </returns></method>
  62. <method name="push"><type>bool</type><parameter name="t"><paramtype>T const &amp;</paramtype></parameter><description><para>Pushes object t to the queue.</para><para>
  63. <note><para>Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated from the OS. This may not be lock-free. </para>
  64. </note>
  65. </para></description><postconditions><para>object will be pushed to the queue, if internal node can be allocated </para>
  66. </postconditions><returns><para>true, if the push operation is successful.</para>
  67. </returns></method>
  68. <method name="bounded_push"><type>bool</type><parameter name="t"><paramtype>T const &amp;</paramtype></parameter><description><para>Pushes object t to the queue.</para><para>
  69. <note><para>Thread-safe and non-blocking. If internal memory pool is exhausted, operation will fail </para>
  70. </note>
  71. </para></description><postconditions><para>object will be pushed to the queue, if internal node can be allocated </para>
  72. </postconditions><returns><para>true, if the push operation is successful.</para>
  73. </returns><throws><simpara><classname>if</classname> memory allocator throws </simpara></throws></method>
  74. <method name="unsynchronized_push"><type>bool</type><parameter name="t"><paramtype>T const &amp;</paramtype></parameter><description><para>Pushes object t to the queue.</para><para>
  75. <note><para>Not Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated from the OS. This may not be lock-free. </para>
  76. </note>
  77. </para></description><postconditions><para>object will be pushed to the queue, if internal node can be allocated </para>
  78. </postconditions><returns><para>true, if the push operation is successful.</para>
  79. </returns><throws><simpara><classname>if</classname> memory allocator throws </simpara></throws></method>
  80. <method name="pop"><type>bool</type><parameter name="ret"><paramtype>T &amp;</paramtype></parameter><description><para>Pops object from queue.</para><para>
  81. <note><para>Thread-safe and non-blocking </para>
  82. </note>
  83. </para></description><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  84. </postconditions><returns><para>true, if the pop operation is successful, false if queue was empty.</para>
  85. </returns></method>
  86. <method name="pop"><type>bool</type><template>
  87. <template-type-parameter name="U"/>
  88. </template><parameter name="ret"><paramtype>U &amp;</paramtype></parameter><description><para>Pops object from queue.</para><para>
  89. <note><para>Thread-safe and non-blocking </para>
  90. </note>
  91. </para></description><requires><para>type U must be constructible by T and copyable, or T must be convertible to U </para>
  92. </requires><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  93. </postconditions><returns><para>true, if the pop operation is successful, false if queue was empty.</para>
  94. </returns></method>
  95. <method name="unsynchronized_pop"><type>bool</type><parameter name="ret"><paramtype>T &amp;</paramtype></parameter><description><para>Pops object from queue.</para><para>
  96. <note><para>Not thread-safe, but non-blocking </para>
  97. </note>
  98. </para></description><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  99. </postconditions><returns><para>true, if the pop operation is successful, false if queue was empty.</para>
  100. </returns></method>
  101. <method name="unsynchronized_pop"><type>bool</type><template>
  102. <template-type-parameter name="U"/>
  103. </template><parameter name="ret"><paramtype>U &amp;</paramtype></parameter><description><para>Pops object from queue.</para><para>
  104. <note><para>Not thread-safe, but non-blocking </para>
  105. </note>
  106. </para></description><requires><para>type U must be constructible by T and copyable, or T must be convertible to U </para>
  107. </requires><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  108. </postconditions><returns><para>true, if the pop operation is successful, false if queue was empty.</para>
  109. </returns></method>
  110. <method name="consume_one"><type>bool</type><template>
  111. <template-type-parameter name="Functor"/>
  112. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes one element via a functor</para><para>pops one element from the queue and applies the functor on this object</para><para>
  113. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  114. </note>
  115. </para></description><returns><para>true, if one element was consumed</para>
  116. </returns></method>
  117. <method name="consume_one"><type>bool</type><template>
  118. <template-type-parameter name="Functor"/>
  119. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes one element via a functor</para><para>pops one element from the queue and applies the functor on this object</para><para>
  120. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  121. </note>
  122. </para></description><returns><para>true, if one element was consumed</para>
  123. </returns></method>
  124. <method name="consume_all"><type>size_t</type><template>
  125. <template-type-parameter name="Functor"/>
  126. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>sequentially pops all elements from the queue and applies the functor on each object</para><para>
  127. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  128. </note>
  129. </para></description><returns><para>number of elements that are consumed</para>
  130. </returns></method>
  131. <method name="consume_all"><type>size_t</type><template>
  132. <template-type-parameter name="Functor"/>
  133. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>sequentially pops all elements from the queue and applies the functor on each object</para><para>
  134. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  135. </note>
  136. </para></description><returns><para>number of elements that are consumed</para>
  137. </returns></method>
  138. </method-group>
  139. <destructor><parameter name=""><paramtype>void</paramtype></parameter><description><para>Destroys queue, free all nodes from freelist. </para></description></destructor>
  140. </class></namespace>
  141. </namespace>
  142. </header>
  143. <header name="boost/lockfree/spsc_queue.hpp">
  144. <namespace name="boost">
  145. <namespace name="lockfree">
  146. <class name="spsc_queue"><template>
  147. <template-type-parameter name="T"/>
  148. <template-type-parameter name="A0"/>
  149. <template-type-parameter name="A1"/>
  150. </template><description><para>The <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> class provides a single-writer/single-reader fifo queue, pushing and popping is wait-free.</para><para><emphasis role="bold">Policies:</emphasis> <itemizedlist>
  151. <listitem><para><computeroutput>boost::lockfree::capacity&lt;&gt;</computeroutput>, optional <sbr/>
  152. If this template argument is passed to the options, the size of the ringbuffer is set at compile-time.</para>
  153. </listitem><listitem><para><computeroutput>boost::lockfree::allocator&lt;&gt;</computeroutput>, defaults to <computeroutput><classname alt="boost::lockfree::allocator">boost::lockfree::allocator</classname>&lt;std::allocator&lt;T&gt;&gt;</computeroutput> <sbr/>
  154. Specifies the allocator that is used to allocate the ringbuffer. This option is only valid, if the ringbuffer is configured to be sized at run-time</para>
  155. </listitem></itemizedlist>
  156. </para><para><emphasis role="bold">Requirements:</emphasis> <itemizedlist>
  157. <listitem><para>T must have a default constructor</para>
  158. </listitem><listitem><para>T must be copyable </para>
  159. </listitem></itemizedlist>
  160. </para></description><struct name="implementation_defined"><template>
  161. <template-type-parameter name="T"/>
  162. <template-nontype-parameter name="Options"><type>typename ...</type></template-nontype-parameter>
  163. </template><typedef name="allocator"><type>allocator_arg</type></typedef>
  164. <typedef name="size_type"><type>std::size_t</type></typedef>
  165. </struct><constructor><parameter name=""><paramtype>void</paramtype></parameter><description><para>Constructs a <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname></para><para>
  166. </para></description><requires><para><classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> must be configured to be sized at compile-time </para>
  167. </requires></constructor>
  168. <constructor specifiers="explicit"><template>
  169. <template-type-parameter name="U"/>
  170. </template><parameter name=""><paramtype><emphasis>unspecified</emphasis></paramtype></parameter></constructor>
  171. <constructor specifiers="explicit"><parameter name=""><paramtype>allocator const &amp;</paramtype></parameter></constructor>
  172. <constructor specifiers="explicit"><parameter name="element_count"><paramtype>size_type</paramtype></parameter><description><para>Constructs a <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> for element_count elements</para><para>
  173. </para></description><requires><para><classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> must be configured to be sized at run-time </para>
  174. </requires></constructor>
  175. <constructor><template>
  176. <template-type-parameter name="U"/>
  177. </template><parameter name="element_count"><paramtype>size_type</paramtype></parameter><parameter name="alloc"><paramtype><emphasis>unspecified</emphasis></paramtype></parameter></constructor>
  178. <constructor><parameter name="element_count"><paramtype>size_type</paramtype></parameter><parameter name="alloc"><paramtype>allocator_arg const &amp;</paramtype></parameter></constructor>
  179. <typedef name="value_type"><type>T</type></typedef>
  180. <typedef name="allocator"><type>implementation_defined::allocator</type></typedef>
  181. <typedef name="size_type"><type>implementation_defined::size_type</type></typedef>
  182. <method-group name="public member functions">
  183. <method name="push"><type>bool</type><parameter name="t"><paramtype>T const &amp;</paramtype></parameter><description><para>Pushes object t to the ringbuffer.</para><para>
  184. <note><para>Thread-safe and wait-free </para>
  185. </note>
  186. </para></description><requires><para>only one thread is allowed to push data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  187. </requires><postconditions><para>object will be pushed to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname>, unless it is full. </para>
  188. </postconditions><returns><para>true, if the push operation is successful.</para>
  189. </returns></method>
  190. <method name="pop"><type>bool</type><description><para>Pops one object from ringbuffer.</para><para>
  191. <note><para>Thread-safe and wait-free </para>
  192. </note>
  193. </para></description><requires><para>only one thread is allowed to pop data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  194. </requires><postconditions><para>if ringbuffer is not empty, object will be discarded. </para>
  195. </postconditions><returns><para>true, if the pop operation is successful, false if ringbuffer was empty.</para>
  196. </returns></method>
  197. <method name="pop"><type>boost::enable_if&lt; typename is_convertible&lt; T, U &gt;::type, bool &gt;::type</type><template>
  198. <template-type-parameter name="U"/>
  199. </template><parameter name="ret"><paramtype>U &amp;</paramtype></parameter><description><para>Pops one object from ringbuffer.</para><para>
  200. <note><para>Thread-safe and wait-free </para>
  201. </note>
  202. </para></description><requires><para>only one thread is allowed to pop data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  203. </requires><postconditions><para>if ringbuffer is not empty, object will be copied to ret. </para>
  204. </postconditions><returns><para>true, if the pop operation is successful, false if ringbuffer was empty.</para>
  205. </returns></method>
  206. <method name="push"><type>size_type</type><parameter name="t"><paramtype>T const *</paramtype></parameter><parameter name="size"><paramtype>size_type</paramtype></parameter><description><para>Pushes as many objects from the array t as there is space.</para><para>
  207. <note><para>Thread-safe and wait-free </para>
  208. </note>
  209. </para></description><requires><para>only one thread is allowed to push data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  210. </requires><returns><para>number of pushed items</para>
  211. </returns></method>
  212. <method name="push"><type>size_type</type><template>
  213. <template-nontype-parameter name="size"><type>size_type</type></template-nontype-parameter>
  214. </template><parameter name="t"><paramtype>T const (&amp;)</paramtype></parameter><description><para>Pushes as many objects from the array t as there is space available.</para><para>
  215. <note><para>Thread-safe and wait-free </para>
  216. </note>
  217. </para></description><requires><para>only one thread is allowed to push data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  218. </requires><returns><para>number of pushed items</para>
  219. </returns></method>
  220. <method name="push"><type>ConstIterator</type><template>
  221. <template-type-parameter name="ConstIterator"/>
  222. </template><parameter name="begin"><paramtype>ConstIterator</paramtype></parameter><parameter name="end"><paramtype>ConstIterator</paramtype></parameter><description><para>Pushes as many objects from the range [begin, end) as there is space .</para><para>
  223. <note><para>Thread-safe and wait-free </para>
  224. </note>
  225. </para></description><requires><para>only one thread is allowed to push data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  226. </requires><returns><para>iterator to the first element, which has not been pushed</para>
  227. </returns></method>
  228. <method name="pop"><type>size_type</type><parameter name="ret"><paramtype>T *</paramtype></parameter><parameter name="size"><paramtype>size_type</paramtype></parameter><description><para>Pops a maximum of size objects from ringbuffer.</para><para>
  229. <note><para>Thread-safe and wait-free </para>
  230. </note>
  231. </para></description><requires><para>only one thread is allowed to pop data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  232. </requires><returns><para>number of popped items</para>
  233. </returns></method>
  234. <method name="pop"><type>size_type</type><template>
  235. <template-nontype-parameter name="size"><type>size_type</type></template-nontype-parameter>
  236. </template><parameter name="ret"><paramtype>T(&amp;)</paramtype></parameter><description><para>Pops a maximum of size objects from <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname>.</para><para>
  237. <note><para>Thread-safe and wait-free </para>
  238. </note>
  239. </para></description><requires><para>only one thread is allowed to pop data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  240. </requires><returns><para>number of popped items</para>
  241. </returns></method>
  242. <method name="pop"><type>boost::disable_if&lt; typename is_convertible&lt; T, OutputIterator &gt;::type, size_type &gt;::type</type><template>
  243. <template-type-parameter name="OutputIterator"/>
  244. </template><parameter name="it"><paramtype>OutputIterator</paramtype></parameter><description><para>Pops objects to the output iterator it</para><para>
  245. <note><para>Thread-safe and wait-free </para>
  246. </note>
  247. </para></description><requires><para>only one thread is allowed to pop data to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname> </para>
  248. </requires><returns><para>number of popped items</para>
  249. </returns></method>
  250. <method name="consume_one"><type>bool</type><template>
  251. <template-type-parameter name="Functor"/>
  252. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes one element via a functor</para><para>pops one element from the queue and applies the functor on this object</para><para>
  253. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  254. </note>
  255. </para></description><returns><para>true, if one element was consumed</para>
  256. </returns></method>
  257. <method name="consume_one"><type>bool</type><template>
  258. <template-type-parameter name="Functor"/>
  259. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes one element via a functor</para><para>pops one element from the queue and applies the functor on this object</para><para>
  260. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  261. </note>
  262. </para></description><returns><para>true, if one element was consumed</para>
  263. </returns></method>
  264. <method name="consume_all"><type>size_type</type><template>
  265. <template-type-parameter name="Functor"/>
  266. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>sequentially pops all elements from the queue and applies the functor on each object</para><para>
  267. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  268. </note>
  269. </para></description><returns><para>number of elements that are consumed</para>
  270. </returns></method>
  271. <method name="consume_all"><type>size_type</type><template>
  272. <template-type-parameter name="Functor"/>
  273. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>sequentially pops all elements from the queue and applies the functor on each object</para><para>
  274. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  275. </note>
  276. </para></description><returns><para>number of elements that are consumed</para>
  277. </returns></method>
  278. <method name="read_available" cv="const"><type>size_type</type><description><para>get number of elements that are available for read</para><para>
  279. <note><para>Thread-safe and wait-free, should only be called from the consumer thread </para>
  280. </note>
  281. </para></description><returns><para>number of available elements that can be popped from the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname></para>
  282. </returns></method>
  283. <method name="write_available" cv="const"><type>size_type</type><description><para>get write space to write elements</para><para>
  284. <note><para>Thread-safe and wait-free, should only be called from the producer thread </para>
  285. </note>
  286. </para></description><returns><para>number of elements that can be pushed to the <classname alt="boost::lockfree::spsc_queue">spsc_queue</classname></para>
  287. </returns></method>
  288. <method name="front" cv="const"><type>const T &amp;</type><description><para>get reference to element in the front of the queue</para><para>Availability of front element can be checked using read_available().</para><para>
  289. <note><para>Thread-safe and wait-free </para>
  290. </note>
  291. </para></description><requires><para>only a consuming thread is allowed to check front element </para>
  292. </requires><requires><para>read_available() &gt; 0. If ringbuffer is empty, it's undefined behaviour to invoke this method. </para>
  293. </requires><returns><para>reference to the first element in the queue</para>
  294. </returns></method>
  295. <method name="front"><type>T &amp;</type><description><para>get reference to element in the front of the queue</para><para>Availability of front element can be checked using read_available().</para><para>
  296. <note><para>Thread-safe and wait-free </para>
  297. </note>
  298. </para></description><requires><para>only a consuming thread is allowed to check front element </para>
  299. </requires><requires><para>read_available() &gt; 0. If ringbuffer is empty, it's undefined behaviour to invoke this method. </para>
  300. </requires><returns><para>reference to the first element in the queue</para>
  301. </returns></method>
  302. <method name="reset"><type>void</type><parameter name=""><paramtype>void</paramtype></parameter><description><para>reset the ringbuffer</para><para><note><para>Not thread-safe </para>
  303. </note>
  304. </para></description></method>
  305. </method-group>
  306. </class></namespace>
  307. </namespace>
  308. </header>
  309. <header name="boost/lockfree/stack.hpp">
  310. <namespace name="boost">
  311. <namespace name="lockfree">
  312. <class name="stack"><template>
  313. <template-type-parameter name="T"/>
  314. <template-type-parameter name="A0"/>
  315. <template-type-parameter name="A1"/>
  316. <template-type-parameter name="A2"/>
  317. </template><description><para>The stack class provides a multi-writer/multi-reader stack, pushing and popping is lock-free, construction/destruction has to be synchronized. It uses a freelist for memory management, freed nodes are pushed to the freelist and not returned to the OS before the stack is destroyed.</para><para><emphasis role="bold">Policies:</emphasis> </para><para><itemizedlist>
  318. <listitem><para><computeroutput>boost::lockfree::fixed_sized&lt;&gt;</computeroutput>, defaults to <computeroutput>boost::lockfree::fixed_sized&lt;false&gt;</computeroutput> <sbr/>
  319. Can be used to completely disable dynamic memory allocations during push in order to ensure lockfree behavior.<sbr/>
  320. If the data structure is configured as fixed-sized, the internal nodes are stored inside an array and they are addressed by array indexing. This limits the possible size of the stack to the number of elements that can be addressed by the index type (usually 2**16-2), but on platforms that lack double-width compare-and-exchange instructions, this is the best way to achieve lock-freedom.</para>
  321. </listitem><listitem><para><computeroutput>boost::lockfree::capacity&lt;&gt;</computeroutput>, optional <sbr/>
  322. If this template argument is passed to the options, the size of the stack is set at compile-time. <sbr/>
  323. It this option implies <computeroutput>fixed_sized&lt;true&gt;</computeroutput> </para>
  324. </listitem><listitem><para><computeroutput>boost::lockfree::allocator&lt;&gt;</computeroutput>, defaults to <computeroutput><classname alt="boost::lockfree::allocator">boost::lockfree::allocator</classname>&lt;std::allocator&lt;void&gt;&gt;</computeroutput> <sbr/>
  325. Specifies the allocator that is used for the internal freelist</para>
  326. </listitem></itemizedlist>
  327. </para><para><emphasis role="bold">Requirements:</emphasis> <itemizedlist>
  328. <listitem><para>T must have a copy constructor </para>
  329. </listitem></itemizedlist>
  330. </para></description><struct name="implementation_defined"><template>
  331. <template-type-parameter name="T"/>
  332. <template-nontype-parameter name="Options"><type>typename ...</type></template-nontype-parameter>
  333. </template><typedef name="allocator"><type>node_allocator</type></typedef>
  334. <typedef name="size_type"><type>std::size_t</type></typedef>
  335. </struct><struct name="node"><template>
  336. <template-type-parameter name="T"/>
  337. <template-nontype-parameter name="Options"><type>typename ...</type></template-nontype-parameter>
  338. </template><typedef name="handle_t"><type><emphasis>unspecified</emphasis></type></typedef>
  339. <data-member name="next"><type>handle_t</type></data-member>
  340. <data-member name="v"><type>const T</type></data-member>
  341. <method-group name="public member functions">
  342. </method-group>
  343. <constructor><parameter name="val"><paramtype>T const &amp;</paramtype></parameter></constructor>
  344. </struct><constructor><parameter name=""><paramtype>void</paramtype></parameter><purpose>Construct stack. </purpose></constructor>
  345. <constructor specifiers="explicit"><template>
  346. <template-type-parameter name="U"/>
  347. </template><parameter name="alloc"><paramtype><emphasis>unspecified</emphasis></paramtype></parameter></constructor>
  348. <constructor specifiers="explicit"><parameter name="alloc"><paramtype>allocator const &amp;</paramtype></parameter></constructor>
  349. <constructor specifiers="explicit"><parameter name="n"><paramtype>size_type</paramtype></parameter><purpose>Construct stack, allocate n nodes for the freelist. </purpose></constructor>
  350. <constructor><template>
  351. <template-type-parameter name="U"/>
  352. </template><parameter name="n"><paramtype>size_type</paramtype></parameter><parameter name="alloc"><paramtype><emphasis>unspecified</emphasis></paramtype></parameter></constructor>
  353. <method-group name="private member functions">
  354. <method name="BOOST_STATIC_ASSERT"><type/><parameter name=""><paramtype>boost::is_copy_constructible&lt; T &gt;::value</paramtype></parameter></method>
  355. <method name="BOOST_STATIC_ASSERT"><type/><parameter name=""><paramtype>(mpl::if_c&lt; has_capacity, mpl::bool_&lt; <classname>capacity</classname> - 1&lt; boost::integer_traits&lt; boost::uint16_t &gt;::const_max &gt;, mpl::true_ &gt;::type::value)</paramtype></parameter></method>
  356. <method name="BOOST_DELETED_FUNCTION"><type/><parameter name=""><paramtype><classname>stack</classname>(<classname>stack</classname> const &amp;)</paramtype></parameter></method>
  357. <method name="is_lock_free" cv="const"><type>bool</type><parameter name=""><paramtype>void</paramtype></parameter><description><para>
  358. <warning><para>It only checks, if the top stack node and the freelist can be modified in a lock-free manner. On most platforms, the whole implementation is lock-free, if this is true. Using c++0x-style atomics, there is no possibility to provide a completely accurate implementation, because one would need to test every internal node, which is impossible if further nodes will be allocated from the operating system. </para>
  359. </warning>
  360. </para></description><returns><para>true, if implementation is lock-free.</para>
  361. </returns></method>
  362. <method name="reserve"><type>void</type><parameter name="n"><paramtype>size_type</paramtype></parameter><description><para>Allocate n nodes for freelist</para><para>
  363. <note><para>thread-safe, may block if memory allocator blocks </para>
  364. </note>
  365. </para></description><requires><para>only valid if no capacity&lt;&gt; argument given </para>
  366. </requires></method>
  367. <method name="reserve_unsafe"><type>void</type><parameter name="n"><paramtype>size_type</paramtype></parameter><description><para>Allocate n nodes for freelist</para><para>
  368. <note><para>not thread-safe, may block if memory allocator blocks </para>
  369. </note>
  370. </para></description><requires><para>only valid if no capacity&lt;&gt; argument given </para>
  371. </requires></method>
  372. <method name="initialize"><type>void</type><parameter name=""><paramtype>void</paramtype></parameter></method>
  373. <method name="link_nodes_atomic"><type>void</type><parameter name="new_top_node"><paramtype>node *</paramtype></parameter><parameter name="end_node"><paramtype>node *</paramtype></parameter></method>
  374. <method name="link_nodes_unsafe"><type>void</type><parameter name="new_top_node"><paramtype>node *</paramtype></parameter><parameter name="end_node"><paramtype>node *</paramtype></parameter></method>
  375. <method name="prepare_node_list"><type>tuple&lt; node *, node * &gt;</type><template>
  376. <template-nontype-parameter name="Threadsafe"><type>bool</type></template-nontype-parameter>
  377. <template-nontype-parameter name="Bounded"><type>bool</type></template-nontype-parameter>
  378. <template-type-parameter name="ConstIterator"/>
  379. </template><parameter name="begin"><paramtype>ConstIterator</paramtype></parameter><parameter name="end"><paramtype>ConstIterator</paramtype></parameter><parameter name="ret"><paramtype>ConstIterator &amp;</paramtype></parameter></method>
  380. <method name="do_push"><type>bool</type><template>
  381. <template-nontype-parameter name="Bounded"><type>bool</type></template-nontype-parameter>
  382. </template><parameter name="v"><paramtype>T const &amp;</paramtype></parameter></method>
  383. <method name="do_push"><type>ConstIterator</type><template>
  384. <template-nontype-parameter name="Bounded"><type>bool</type></template-nontype-parameter>
  385. <template-type-parameter name="ConstIterator"/>
  386. </template><parameter name="begin"><paramtype>ConstIterator</paramtype></parameter><parameter name="end"><paramtype>ConstIterator</paramtype></parameter></method>
  387. </method-group>
  388. <destructor><parameter name=""><paramtype>void</paramtype></parameter><description><para>Destroys stack, free all nodes from freelist.</para><para><note><para>not thread-safe </para>
  389. </note>
  390. </para></description></destructor>
  391. <method-group name="public member functions">
  392. <method name="push"><type>bool</type><parameter name="v"><paramtype>T const &amp;</paramtype></parameter><description><para>Pushes object t to the stack.</para><para>
  393. <note><para>Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated from the OS. This may not be lock-free. </para>
  394. </note>
  395. </para></description><postconditions><para>object will be pushed to the stack, if internal node can be allocated </para>
  396. </postconditions><returns><para>true, if the push operation is successful.</para>
  397. </returns><throws><simpara><classname>if</classname> memory allocator throws </simpara></throws></method>
  398. <method name="bounded_push"><type>bool</type><parameter name="v"><paramtype>T const &amp;</paramtype></parameter><description><para>Pushes object t to the stack.</para><para>
  399. <note><para>Thread-safe and non-blocking. If internal memory pool is exhausted, the push operation will fail </para>
  400. </note>
  401. </para></description><postconditions><para>object will be pushed to the stack, if internal node can be allocated </para>
  402. </postconditions><returns><para>true, if the push operation is successful.</para>
  403. </returns></method>
  404. <method name="push"><type>ConstIterator</type><template>
  405. <template-type-parameter name="ConstIterator"/>
  406. </template><parameter name="begin"><paramtype>ConstIterator</paramtype></parameter><parameter name="end"><paramtype>ConstIterator</paramtype></parameter><description><para>Pushes as many objects from the range [begin, end) as freelist node can be allocated.</para><para>
  407. <note><para>Operation is applied atomically </para>
  408. </note>
  409. <note><para>Thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated from the OS. This may not be lock-free. </para>
  410. </note>
  411. </para></description><returns><para>iterator to the first element, which has not been pushed</para>
  412. </returns><throws><simpara><classname>if</classname> memory allocator throws </simpara></throws></method>
  413. <method name="bounded_push"><type>ConstIterator</type><template>
  414. <template-type-parameter name="ConstIterator"/>
  415. </template><parameter name="begin"><paramtype>ConstIterator</paramtype></parameter><parameter name="end"><paramtype>ConstIterator</paramtype></parameter><description><para>Pushes as many objects from the range [begin, end) as freelist node can be allocated.</para><para>
  416. <note><para>Operation is applied atomically </para>
  417. </note>
  418. <note><para>Thread-safe and non-blocking. If internal memory pool is exhausted, the push operation will fail </para>
  419. </note>
  420. </para></description><returns><para>iterator to the first element, which has not been pushed</para>
  421. </returns><throws><simpara><classname>if</classname> memory allocator throws </simpara></throws></method>
  422. <method name="unsynchronized_push"><type>bool</type><parameter name="v"><paramtype>T const &amp;</paramtype></parameter><description><para>Pushes object t to the stack.</para><para>
  423. <note><para>Not thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated from the OS. This may not be lock-free. </para>
  424. </note>
  425. </para></description><postconditions><para>object will be pushed to the stack, if internal node can be allocated </para>
  426. </postconditions><returns><para>true, if the push operation is successful.</para>
  427. </returns><throws><simpara><classname>if</classname> memory allocator throws </simpara></throws></method>
  428. <method name="unsynchronized_push"><type>ConstIterator</type><template>
  429. <template-type-parameter name="ConstIterator"/>
  430. </template><parameter name="begin"><paramtype>ConstIterator</paramtype></parameter><parameter name="end"><paramtype>ConstIterator</paramtype></parameter><description><para>Pushes as many objects from the range [begin, end) as freelist node can be allocated.</para><para>
  431. <note><para>Not thread-safe. If internal memory pool is exhausted and the memory pool is not fixed-sized, a new node will be allocated from the OS. This may not be lock-free. </para>
  432. </note>
  433. </para></description><returns><para>iterator to the first element, which has not been pushed</para>
  434. </returns><throws><simpara><classname>if</classname> memory allocator throws </simpara></throws></method>
  435. <method name="pop"><type>bool</type><parameter name="ret"><paramtype>T &amp;</paramtype></parameter><description><para>Pops object from stack.</para><para>
  436. <note><para>Thread-safe and non-blocking </para>
  437. </note>
  438. </para></description><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  439. </postconditions><returns><para>true, if the pop operation is successful, false if stack was empty.</para>
  440. </returns></method>
  441. <method name="pop"><type>bool</type><template>
  442. <template-type-parameter name="U"/>
  443. </template><parameter name="ret"><paramtype>U &amp;</paramtype></parameter><description><para>Pops object from stack.</para><para>
  444. <note><para>Thread-safe and non-blocking </para>
  445. </note>
  446. </para></description><requires><para>type T must be convertible to U </para>
  447. </requires><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  448. </postconditions><returns><para>true, if the pop operation is successful, false if stack was empty.</para>
  449. </returns></method>
  450. <method name="unsynchronized_pop"><type>bool</type><parameter name="ret"><paramtype>T &amp;</paramtype></parameter><description><para>Pops object from stack.</para><para>
  451. <note><para>Not thread-safe, but non-blocking </para>
  452. </note>
  453. </para></description><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  454. </postconditions><returns><para>true, if the pop operation is successful, false if stack was empty.</para>
  455. </returns></method>
  456. <method name="unsynchronized_pop"><type>bool</type><template>
  457. <template-type-parameter name="U"/>
  458. </template><parameter name="ret"><paramtype>U &amp;</paramtype></parameter><description><para>Pops object from stack.</para><para>
  459. <note><para>Not thread-safe, but non-blocking </para>
  460. </note>
  461. </para></description><requires><para>type T must be convertible to U </para>
  462. </requires><postconditions><para>if pop operation is successful, object will be copied to ret. </para>
  463. </postconditions><returns><para>true, if the pop operation is successful, false if stack was empty.</para>
  464. </returns></method>
  465. <method name="consume_one"><type>bool</type><template>
  466. <template-type-parameter name="Functor"/>
  467. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes one element via a functor</para><para>pops one element from the stack and applies the functor on this object</para><para>
  468. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  469. </note>
  470. </para></description><returns><para>true, if one element was consumed</para>
  471. </returns></method>
  472. <method name="consume_one"><type>bool</type><template>
  473. <template-type-parameter name="Functor"/>
  474. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes one element via a functor</para><para>pops one element from the stack and applies the functor on this object</para><para>
  475. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  476. </note>
  477. </para></description><returns><para>true, if one element was consumed</para>
  478. </returns></method>
  479. <method name="consume_all"><type>size_t</type><template>
  480. <template-type-parameter name="Functor"/>
  481. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>sequentially pops all elements from the stack and applies the functor on each object</para><para>
  482. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  483. </note>
  484. </para></description><returns><para>number of elements that are consumed</para>
  485. </returns></method>
  486. <method name="consume_all"><type>size_t</type><template>
  487. <template-type-parameter name="Functor"/>
  488. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>sequentially pops all elements from the stack and applies the functor on each object</para><para>
  489. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  490. </note>
  491. </para></description><returns><para>number of elements that are consumed</para>
  492. </returns></method>
  493. <method name="consume_all_atomic"><type>size_t</type><template>
  494. <template-type-parameter name="Functor"/>
  495. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>atomically pops all elements from the stack and applies the functor on each object</para><para>
  496. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  497. </note>
  498. </para></description><returns><para>number of elements that are consumed</para>
  499. </returns></method>
  500. <method name="consume_all_atomic"><type>size_t</type><template>
  501. <template-type-parameter name="Functor"/>
  502. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>atomically pops all elements from the stack and applies the functor on each object</para><para>
  503. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  504. </note>
  505. </para></description><returns><para>number of elements that are consumed</para>
  506. </returns></method>
  507. <method name="consume_all_atomic_reversed"><type>size_t</type><template>
  508. <template-type-parameter name="Functor"/>
  509. </template><parameter name="f"><paramtype>Functor &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>atomically pops all elements from the stack and applies the functor on each object in reversed order</para><para>
  510. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  511. </note>
  512. </para></description><returns><para>number of elements that are consumed</para>
  513. </returns></method>
  514. <method name="consume_all_atomic_reversed"><type>size_t</type><template>
  515. <template-type-parameter name="Functor"/>
  516. </template><parameter name="f"><paramtype>Functor const &amp;</paramtype></parameter><description><para>consumes all elements via a functor</para><para>atomically pops all elements from the stack and applies the functor on each object in reversed order</para><para>
  517. <note><para>Thread-safe and non-blocking, if functor is thread-safe and non-blocking </para>
  518. </note>
  519. </para></description><returns><para>number of elements that are consumed</para>
  520. </returns></method>
  521. <method name="empty" cv="const"><type>bool</type><parameter name=""><paramtype>void</paramtype></parameter><description><para>
  522. <note><para>It only guarantees that at some point during the execution of the function the stack has been empty. It is rarely practical to use this value in program logic, because the stack can be modified by other threads. </para>
  523. </note>
  524. </para></description><returns><para>true, if stack is empty.</para>
  525. </returns></method>
  526. </method-group>
  527. </class></namespace>
  528. </namespace>
  529. </header>
  530. </library-reference>