forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasstf_1_1TaskQueue.xml
More file actions
414 lines (414 loc) · 29.7 KB
/
Copy pathclasstf_1_1TaskQueue.xml
File metadata and controls
414 lines (414 loc) · 29.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.14">
<compounddef id="classtf_1_1TaskQueue" kind="class" language="C++" prot="public">
<compoundname>tf::TaskQueue</compoundname>
<includes refid="tsq_8hpp" local="no">tsq.hpp</includes>
<innerclass refid="structtf_1_1TaskQueue_1_1Array" prot="private">tf::TaskQueue::Array</innerclass>
<templateparamlist>
<param>
<type>typename</type>
<declname>T</declname>
<defname>T</defname>
</param>
<param>
<type>unsigned</type>
<declname>TF_MAX_PRIORITY</declname>
<defname>TF_MAX_PRIORITY</defname>
<defval>static_cast<unsigned>(<ref refid="namespacetf_1ac9f4add8f716ed323b0bdbbc1d89346fa26a4b44a837bf97b972628509912b4a5" kindref="member">TaskPriority::MAX</ref>)</defval>
</param>
</templateparamlist>
<sectiondef kind="private-attrib">
<memberdef kind="variable" id="classtf_1_1TaskQueue_1a8b8c8e69e04481708b8b17059398a04b" prot="private" static="no" mutable="no">
<type>CachelineAligned< <ref refid="cpp/atomic/atomic" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::atomic</ref>< int64_t > ></type>
<definition>CachelineAligned<std::atomic<int64_t> > tf::TaskQueue< T, TF_MAX_PRIORITY >::_top[TF_MAX_PRIORITY]</definition>
<argsstring>[TF_MAX_PRIORITY]</argsstring>
<name>_top</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="155" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="155" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="classtf_1_1TaskQueue_1aebf6dd0368728d9fa25127020afb9dda" prot="private" static="no" mutable="no">
<type>CachelineAligned< <ref refid="cpp/atomic/atomic" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::atomic</ref>< int64_t > ></type>
<definition>CachelineAligned<std::atomic<int64_t> > tf::TaskQueue< T, TF_MAX_PRIORITY >::_bottom[TF_MAX_PRIORITY]</definition>
<argsstring>[TF_MAX_PRIORITY]</argsstring>
<name>_bottom</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="156" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="156" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="classtf_1_1TaskQueue_1abaadb3c00494c5873bc7fd5d8ec30f06" prot="private" static="no" mutable="no">
<type><ref refid="cpp/atomic/atomic" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::atomic</ref>< Array * ></type>
<definition>std::atomic<Array*> tf::TaskQueue< T, TF_MAX_PRIORITY >::_array[TF_MAX_PRIORITY]</definition>
<argsstring>[TF_MAX_PRIORITY]</argsstring>
<name>_array</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="157" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="157" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="classtf_1_1TaskQueue_1aeb6fedf457596dad3f64af57343613cd" prot="private" static="no" mutable="no">
<type><ref refid="cpp/container/vector" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::vector</ref>< Array * ></type>
<definition>std::vector<Array*> tf::TaskQueue< T, TF_MAX_PRIORITY >::_garbage[TF_MAX_PRIORITY]</definition>
<argsstring>[TF_MAX_PRIORITY]</argsstring>
<name>_garbage</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="158" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="158" bodyend="-1"/>
</memberdef>
</sectiondef>
<sectiondef kind="public-func">
<memberdef kind="function" id="classtf_1_1TaskQueue_1a715574f55d3a05ec4040fc390bfcd632" prot="public" static="no" const="no" explicit="yes" inline="no" virt="non-virtual">
<type></type>
<definition>tf::TaskQueue< T, TF_MAX_PRIORITY >::TaskQueue</definition>
<argsstring>(int64_t capacity=512)</argsstring>
<name>TaskQueue</name>
<param>
<type>int64_t</type>
<declname>capacity</declname>
<defval>512</defval>
</param>
<briefdescription>
<para>constructs the queue with a given capacity </para> </briefdescription>
<detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername>capacity</parametername>
</parameternamelist>
<parameterdescription>
<para>the capacity of the queue (must be power of 2) </para></parameterdescription>
</parameteritem>
</parameterlist>
</para> </detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="169" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="261" bodyend="269"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1a15d5b45f482cba7383512a9c5bcbd7cf" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type></type>
<definition>tf::TaskQueue< T, TF_MAX_PRIORITY >::~TaskQueue</definition>
<argsstring>()</argsstring>
<name>~TaskQueue</name>
<briefdescription>
<para>destructs the queue </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="174" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="273" bodyend="280"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1adfdf70255e24d62c46b31b09c47d78f7" prot="public" static="no" const="yes" explicit="no" inline="no" virt="non-virtual">
<type>bool</type>
<definition>bool tf::TaskQueue< T, TF_MAX_PRIORITY >::empty</definition>
<argsstring>() const noexcept</argsstring>
<name>empty</name>
<briefdescription>
<para>queries if the queue is empty at the time of this call </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="179" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="284" bodyend="291"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1af57eb2ebc4d92120d7eaf868ec57b524" prot="public" static="no" const="yes" explicit="no" inline="no" virt="non-virtual">
<type>bool</type>
<definition>bool tf::TaskQueue< T, TF_MAX_PRIORITY >::empty</definition>
<argsstring>(unsigned priority) const noexcept</argsstring>
<name>empty</name>
<param>
<type>unsigned</type>
<declname>priority</declname>
</param>
<briefdescription>
<para>queries if the queue is empty at a specific priority value </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="184" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="295" bodyend="299"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1ad598bef2211bf4cc99d66d80a12ebb6a" prot="public" static="no" const="yes" explicit="no" inline="no" virt="non-virtual">
<type>size_t</type>
<definition>size_t tf::TaskQueue< T, TF_MAX_PRIORITY >::size</definition>
<argsstring>() const noexcept</argsstring>
<name>size</name>
<briefdescription>
<para>queries the number of items at the time of this call </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="189" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="303" bodyend="307"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1a0386ad90ced931025d14ea955ce40d8c" prot="public" static="no" const="yes" explicit="no" inline="no" virt="non-virtual">
<type>size_t</type>
<definition>size_t tf::TaskQueue< T, TF_MAX_PRIORITY >::size</definition>
<argsstring>(unsigned priority) const noexcept</argsstring>
<name>size</name>
<param>
<type>unsigned</type>
<declname>priority</declname>
</param>
<briefdescription>
<para>queries the number of items with the given priority at the time of this call </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="195" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="311" bodyend="315"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1ad47b2671aa5270bcd05605c4063280ff" prot="public" static="no" const="yes" explicit="no" inline="no" virt="non-virtual">
<type>int64_t</type>
<definition>int64_t tf::TaskQueue< T, TF_MAX_PRIORITY >::capacity</definition>
<argsstring>() const noexcept</argsstring>
<name>capacity</name>
<briefdescription>
<para>queries the capacity of the queue </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="200" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="413" bodyend="419"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1ab868d17013212547d750267710037877" prot="public" static="no" const="yes" explicit="no" inline="no" virt="non-virtual">
<type>int64_t</type>
<definition>int64_t tf::TaskQueue< T, TF_MAX_PRIORITY >::capacity</definition>
<argsstring>(unsigned priority) const noexcept</argsstring>
<name>capacity</name>
<param>
<type>unsigned</type>
<declname>priority</declname>
</param>
<briefdescription>
<para>queries the capacity of the queue at a specific priority value </para> </briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="205" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="423" bodyend="425"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1ab90cef7de0b45650b67971db0ccbef76" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>TF_FORCE_INLINE void</type>
<definition>TF_FORCE_INLINE void tf::TaskQueue< T, TF_MAX_PRIORITY >::push</definition>
<argsstring>(T item, unsigned priority)</argsstring>
<name>push</name>
<param>
<type>T</type>
<declname>item</declname>
</param>
<param>
<type>unsigned</type>
<declname>priority</declname>
</param>
<briefdescription>
<para>inserts an item to the queue </para> </briefdescription>
<detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername>item</parametername>
</parameternamelist>
<parameterdescription>
<para>the item to push to the queue </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername>priority</parametername>
</parameternamelist>
<parameterdescription>
<para>priority value of the item to push (default = 0)</para></parameterdescription>
</parameteritem>
</parameterlist>
Only the owner thread can insert an item to the queue. The operation can trigger the queue to resize its capacity if more space is required. </para> </detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="217" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="319" bodyend="333"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1a3df0b3554e814385d23ee603941391df" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>T</type>
<definition>T tf::TaskQueue< T, TF_MAX_PRIORITY >::pop</definition>
<argsstring>()</argsstring>
<name>pop</name>
<briefdescription>
<para>pops out an item from the queue </para> </briefdescription>
<detaileddescription>
<para>Only the owner thread can pop out an item from the queue. The return can be a <computeroutput>nullptr</computeroutput> if this operation failed (empty queue). </para> </detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="225" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="337" bodyend="344"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1ab486c2b496bc5ebc84122924921e5632" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>TF_FORCE_INLINE T</type>
<definition>TF_FORCE_INLINE T tf::TaskQueue< T, TF_MAX_PRIORITY >::pop</definition>
<argsstring>(unsigned priority)</argsstring>
<name>pop</name>
<param>
<type>unsigned</type>
<declname>priority</declname>
</param>
<briefdescription>
<para>pops out an item with a specific priority value from the queue </para> </briefdescription>
<detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername>priority</parametername>
</parameternamelist>
<parameterdescription>
<para>priority of the item to pop</para></parameterdescription>
</parameteritem>
</parameterlist>
Only the owner thread can pop out an item from the queue. The return can be a <computeroutput>nullptr</computeroutput> if this operation failed (empty queue). </para> </detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="235" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="348" bodyend="375"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1a23e13cb9f98316b26c00ce494aa2f0c6" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>T</type>
<definition>T tf::TaskQueue< T, TF_MAX_PRIORITY >::steal</definition>
<argsstring>()</argsstring>
<name>steal</name>
<briefdescription>
<para>steals an item from the queue </para> </briefdescription>
<detaileddescription>
<para>Any threads can try to steal an item from the queue. The return can be a <computeroutput>nullptr</computeroutput> if this operation failed (not necessary empty). </para> </detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="243" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="379" bodyend="386"/>
</memberdef>
<memberdef kind="function" id="classtf_1_1TaskQueue_1aca896b5d59a78a018aeb313760ca735a" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>T</type>
<definition>T tf::TaskQueue< T, TF_MAX_PRIORITY >::steal</definition>
<argsstring>(unsigned priority)</argsstring>
<name>steal</name>
<param>
<type>unsigned</type>
<declname>priority</declname>
</param>
<briefdescription>
<para>steals an item with a specific priority value from the queue </para> </briefdescription>
<detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername>priority</parametername>
</parameternamelist>
<parameterdescription>
<para>priority of the item to steal</para></parameterdescription>
</parameteritem>
</parameterlist>
Any threads can try to steal an item from the queue. The return can be a <computeroutput>nullptr</computeroutput> if this operation failed (not necessary empty). </para> </detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="253" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="390" bodyend="409"/>
</memberdef>
</sectiondef>
<sectiondef kind="private-func">
<memberdef kind="function" id="classtf_1_1TaskQueue_1a512796f5396f152af2f8249bc5519596" prot="private" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
<type>TF_NO_INLINE Array *</type>
<definition>TF_NO_INLINE TaskQueue< T, TF_MAX_PRIORITY >::Array * tf::TaskQueue< T, TF_MAX_PRIORITY >::resize_array</definition>
<argsstring>(Array *a, unsigned p, std::int64_t b, std::int64_t t)</argsstring>
<name>resize_array</name>
<param>
<type>Array *</type>
<declname>a</declname>
</param>
<param>
<type>unsigned</type>
<declname>p</declname>
</param>
<param>
<type><ref refid="cpp/types/integer" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::int64_t</ref></type>
<declname>b</declname>
</param>
<param>
<type><ref refid="cpp/types/integer" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::int64_t</ref></type>
<declname>t</declname>
</param>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="256" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="429" bodyend="438"/>
</memberdef>
</sectiondef>
<briefdescription>
<para>class to create a lock-free unbounded single-producer multiple-consumer queue </para> </briefdescription>
<detaileddescription>
<para><parameterlist kind="templateparam"><parameteritem>
<parameternamelist>
<parametername>T</parametername>
</parameternamelist>
<parameterdescription>
<para>data type (must be a pointer type) </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername>TF_MAX_PRIORITY</parametername>
</parameternamelist>
<parameterdescription>
<para>maximum level of the priority</para></parameterdescription>
</parameteritem>
</parameterlist>
This class implements the work-stealing queue described in the paper, <ulink url="https://www.di.ens.fr/~zappa/readings/ppopp13.pdf">Correct and Efficient Work-Stealing for Weak Memory Models</ulink>, and extends it to include priority.</para><para>Only the queue owner can perform pop and push operations, while others can steal data from the queue simultaneously. Priority starts from zero (highest priority) to the template value <computeroutput>TF_MAX_PRIORITY-1</computeroutput> (lowest priority). All operations are associated with priority values to indicate the corresponding queues to which an operation is applied.</para><para>The default template value, <computeroutput>TF_MAX_PRIORITY</computeroutput>, is <computeroutput><ref refid="namespacetf_1ac9f4add8f716ed323b0bdbbc1d89346fa26a4b44a837bf97b972628509912b4a5" kindref="member">TaskPriority::MAX</ref></computeroutput> which applies only three priority levels to the task queue.</para><para><programlisting filename=".cpp"><codeline><highlight class="keyword">auto</highlight><highlight class="normal"><sp/>[A,<sp/>B,<sp/>C,<sp/>D,<sp/>E]<sp/>=<sp/>taskflow.<ref refid="classtf_1_1FlowBuilder_1a60d7a666cab71ecfa3010b2efb0d6b57" kindref="member">emplace</ref>(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>[]<sp/>()<sp/>{<sp/>},</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>[&]<sp/>()<sp/>{<sp/></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="cpp/io/basic_ostream" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::cout</ref><sp/><<<sp/></highlight><highlight class="stringliteral">"Task<sp/>B:<sp/>"</highlight><highlight class="normal"><sp/><<<sp/>counter++<sp/><<<sp/></highlight><highlight class="charliteral">'\n'</highlight><highlight class="normal">;<sp/><sp/></highlight><highlight class="comment">//<sp/>0</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>},</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>[&]<sp/>()<sp/>{<sp/></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="cpp/io/basic_ostream" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::cout</ref><sp/><<<sp/></highlight><highlight class="stringliteral">"Task<sp/>C:<sp/>"</highlight><highlight class="normal"><sp/><<<sp/>counter++<sp/><<<sp/></highlight><highlight class="charliteral">'\n'</highlight><highlight class="normal">;<sp/><sp/></highlight><highlight class="comment">//<sp/>2</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>},</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>[&]<sp/>()<sp/>{<sp/></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="cpp/io/basic_ostream" kindref="compound" external="/home/twhuang/Code/taskflow/doxygen/cppreference-doxygen-web.tag.xml">std::cout</ref><sp/><<<sp/></highlight><highlight class="stringliteral">"Task<sp/>D:<sp/>"</highlight><highlight class="normal"><sp/><<<sp/>counter++<sp/><<<sp/></highlight><highlight class="charliteral">'\n'</highlight><highlight class="normal">;<sp/><sp/></highlight><highlight class="comment">//<sp/>1</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>},</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>[]<sp/>()<sp/>{<sp/>}</highlight></codeline>
<codeline><highlight class="normal">);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal">A.<ref refid="classtf_1_1Task_1a8c78c453295a553c1c016e4062da8588" kindref="member">precede</ref>(B,<sp/>C,<sp/>D);<sp/></highlight></codeline>
<codeline><highlight class="normal">E.<ref refid="classtf_1_1Task_1a331b1b726555072e7c7d10941257f664" kindref="member">succeed</ref>(B,<sp/>C,<sp/>D);</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/></highlight></codeline>
<codeline><highlight class="normal">B.<ref refid="classtf_1_1Task_1a65ba160c1464b4084f85bd9d3dd41291" kindref="member">priority</ref>(<ref refid="namespacetf_1ac9f4add8f716ed323b0bdbbc1d89346fab89de3b4b81c4facfac906edf29aec8c" kindref="member">tf::TaskPriority::HIGH</ref>);</highlight></codeline>
<codeline><highlight class="normal">C.<ref refid="classtf_1_1Task_1a65ba160c1464b4084f85bd9d3dd41291" kindref="member">priority</ref>(<ref refid="namespacetf_1ac9f4add8f716ed323b0bdbbc1d89346fa41bc94cbd8eebea13ce0491b2ac11b88" kindref="member">tf::TaskPriority::LOW</ref>);</highlight></codeline>
<codeline><highlight class="normal">D.<ref refid="classtf_1_1Task_1a65ba160c1464b4084f85bd9d3dd41291" kindref="member">priority</ref>(<ref refid="namespacetf_1ac9f4add8f716ed323b0bdbbc1d89346fa1e23852820b9154316c7c06e2b7ba051" kindref="member">tf::TaskPriority::NORMAL</ref>);</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/></highlight></codeline>
<codeline><highlight class="normal">executor.<ref refid="classtf_1_1Executor_1a519777f5783981d534e9e53b99712069" kindref="member">run</ref>(taskflow).wait();</highlight></codeline>
</programlisting></para><para>In the above example, we have a task graph of five tasks, <computeroutput>A</computeroutput>, <computeroutput>B</computeroutput>, <computeroutput>C</computeroutput>, <computeroutput>D</computeroutput>, and <computeroutput>E</computeroutput>, in which <computeroutput>B</computeroutput>, <computeroutput>C</computeroutput>, and <computeroutput>D</computeroutput> can run in simultaneously when <computeroutput>A</computeroutput> finishes. Since we only uses one worker thread in the executor, we can deterministically run <computeroutput>B</computeroutput> first, then <computeroutput>D</computeroutput>, and <computeroutput>C</computeroutput> in order of their priority values. The output is as follows:</para><para><programlisting filename=".shell-session"><codeline><highlight class="normal">Task<sp/>B:<sp/>0</highlight></codeline>
<codeline><highlight class="normal">Task<sp/>D:<sp/>1</highlight></codeline>
<codeline><highlight class="normal">Task<sp/>C:<sp/>2</highlight></codeline>
</programlisting> </para> </detaileddescription>
<location file="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" line="110" column="1" bodyfile="/home/twhuang/Code/taskflow/taskflow/core/tsq.hpp" bodystart="110" bodyend="257"/>
<listofallmembers>
<member refid="classtf_1_1TaskQueue_1abaadb3c00494c5873bc7fd5d8ec30f06" prot="private" virt="non-virtual"><scope>tf::TaskQueue</scope><name>_array</name></member>
<member refid="classtf_1_1TaskQueue_1aebf6dd0368728d9fa25127020afb9dda" prot="private" virt="non-virtual"><scope>tf::TaskQueue</scope><name>_bottom</name></member>
<member refid="classtf_1_1TaskQueue_1aeb6fedf457596dad3f64af57343613cd" prot="private" virt="non-virtual"><scope>tf::TaskQueue</scope><name>_garbage</name></member>
<member refid="classtf_1_1TaskQueue_1a8b8c8e69e04481708b8b17059398a04b" prot="private" virt="non-virtual"><scope>tf::TaskQueue</scope><name>_top</name></member>
<member refid="classtf_1_1TaskQueue_1ad47b2671aa5270bcd05605c4063280ff" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>capacity</name></member>
<member refid="classtf_1_1TaskQueue_1ab868d17013212547d750267710037877" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>capacity</name></member>
<member refid="classtf_1_1TaskQueue_1adfdf70255e24d62c46b31b09c47d78f7" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>empty</name></member>
<member refid="classtf_1_1TaskQueue_1af57eb2ebc4d92120d7eaf868ec57b524" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>empty</name></member>
<member refid="classtf_1_1TaskQueue_1a3df0b3554e814385d23ee603941391df" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>pop</name></member>
<member refid="classtf_1_1TaskQueue_1ab486c2b496bc5ebc84122924921e5632" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>pop</name></member>
<member refid="classtf_1_1TaskQueue_1ab90cef7de0b45650b67971db0ccbef76" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>push</name></member>
<member refid="classtf_1_1TaskQueue_1a512796f5396f152af2f8249bc5519596" prot="private" virt="non-virtual"><scope>tf::TaskQueue</scope><name>resize_array</name></member>
<member refid="classtf_1_1TaskQueue_1ad598bef2211bf4cc99d66d80a12ebb6a" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>size</name></member>
<member refid="classtf_1_1TaskQueue_1a0386ad90ced931025d14ea955ce40d8c" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>size</name></member>
<member refid="classtf_1_1TaskQueue_1a23e13cb9f98316b26c00ce494aa2f0c6" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>steal</name></member>
<member refid="classtf_1_1TaskQueue_1aca896b5d59a78a018aeb313760ca735a" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>steal</name></member>
<member refid="classtf_1_1TaskQueue_1a715574f55d3a05ec4040fc390bfcd632" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>TaskQueue</name></member>
<member refid="classtf_1_1TaskQueue_1a15d5b45f482cba7383512a9c5bcbd7cf" prot="public" virt="non-virtual"><scope>tf::TaskQueue</scope><name>~TaskQueue</name></member>
</listofallmembers>
</compounddef>
</doxygen>