forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasstf_1_1Task.html
More file actions
465 lines (462 loc) · 29.5 KB
/
Copy pathclasstf_1_1Task.html
File metadata and controls
465 lines (462 loc) · 29.5 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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>tf::Task class | Taskflow QuickStart</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
<link rel="stylesheet" href="m-dark+documentation.compiled.css" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#22272e" />
</head>
<body>
<header><nav id="navigation">
<div class="m-container">
<div class="m-row">
<span id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">
<a href="https://taskflow.github.io"><img src="taskflow_logo.png" alt="" />Taskflow</a> <span class="m-breadcrumb">|</span> <a href="index.html" class="m-thin">QuickStart</a>
</span>
<div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
<a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<path id="m-doc-search-icon-path" d="m6 0c-3.31 0-6 2.69-6 6 0 3.31 2.69 6 6 6 1.49 0 2.85-0.541 3.89-1.44-0.0164 0.338 0.147 0.759 0.5 1.15l3.22 3.79c0.552 0.614 1.45 0.665 2 0.115 0.55-0.55 0.499-1.45-0.115-2l-3.79-3.22c-0.392-0.353-0.812-0.515-1.15-0.5 0.895-1.05 1.44-2.41 1.44-3.89 0-3.31-2.69-6-6-6zm0 1.56a4.44 4.44 0 0 1 4.44 4.44 4.44 4.44 0 0 1-4.44 4.44 4.44 4.44 0 0 1-4.44-4.44 4.44 4.44 0 0 1 4.44-4.44z"/>
</svg></a>
<a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
<a id="m-navbar-hide" href="#" title="Hide navigation"></a>
</div>
<div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
<li><a href="pages.html">Handbook</a></li>
<li><a href="namespaces.html">Namespaces</a></li>
</ol>
<ol class="m-col-t-6 m-col-m-none" start="3">
<li><a href="annotated.html">Classes</a></li>
<li><a href="files.html">Files</a></li>
<li class="m-show-m"><a href="#search" class="m-doc-search-icon" title="Search" onclick="return showSearch()"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
<use href="#m-doc-search-icon-path" />
</svg></a></li>
</ol>
</div>
</div>
</div>
</div>
</nav></header>
<main><article>
<div class="m-container m-container-inflatable">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<h1>
<span class="m-breadcrumb"><a href="namespacetf.html">tf</a>::<wbr/></span>Task <span class="m-thin">class</span>
<div class="m-doc-include m-code m-inverted m-text-right"><span class="cp">#include</span> <a class="cpf" href="task_8hpp.html"><taskflow/core/task.hpp></a></div>
</h1>
<p>class to create a task handle over a node in a taskflow graph</p>
<nav class="m-block m-default">
<h3>Contents</h3>
<ul>
<li>
Reference
<ul>
<li><a href="#typeless-methods">Constructors, destructors, conversion operators</a></li>
<li><a href="#pub-methods">Public functions</a></li>
</ul>
</li>
</ul>
</nav>
<p>A task is a wrapper over a node in a taskflow graph. It provides a set of methods for users to access and modify the attributes of the associated node in the taskflow graph. A task is very lightweight object (i.e., only storing a node pointer) that can be trivially copied around, and it does not own the lifetime of the associated node.</p>
<section id="typeless-methods">
<h2><a href="#typeless-methods">Constructors, destructors, conversion operators</a></h2>
<dl class="m-doc">
<dt id="a5ed7ba63e8eeaa0f21fe08c80aa474ba">
<span class="m-doc-wrap-bumper"><a href="#a5ed7ba63e8eeaa0f21fe08c80aa474ba" class="m-doc-self">Task</a>(</span><span class="m-doc-wrap">) <span class="m-label m-flat m-info">defaulted</span></span>
</dt>
<dd>constructs an empty task</dd>
<dt id="a53deffe60d7c758df4265aeb81063928">
<span class="m-doc-wrap-bumper"><a href="#a53deffe60d7c758df4265aeb81063928" class="m-doc-self">Task</a>(</span><span class="m-doc-wrap">const <a href="classtf_1_1Task.html" class="m-doc">Task</a>& other)</span>
</dt>
<dd>constructs the task with the copy of the other task</dd>
</dl>
</section>
<section id="pub-methods">
<h2><a href="#pub-methods">Public functions</a></h2>
<dl class="m-doc">
<dt id="aebdcc47e47a119f261daab673a971458">
<span class="m-doc-wrap-bumper">auto <a href="#aebdcc47e47a119f261daab673a971458" class="m-doc-self">operator=</a>(</span><span class="m-doc-wrap">const <a href="classtf_1_1Task.html" class="m-doc">Task</a>&) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>replaces the contents with a copy of the other task</dd>
<dt id="a4b0e3d6a1985a353626c15970c51c820">
<span class="m-doc-wrap-bumper">auto <a href="#a4b0e3d6a1985a353626c15970c51c820" class="m-doc-self">operator=</a>(</span><span class="m-doc-wrap"><a href="http://en.cppreference.com/w/cpp/types/nullptr_t.html" class="m-doc-external">std::<wbr />nullptr_t</a>) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>replaces the contents with a null pointer</dd>
<dt id="ad87bb498b0a4eae0c375bc59b66dbba8">
<span class="m-doc-wrap-bumper">auto <a href="#ad87bb498b0a4eae0c375bc59b66dbba8" class="m-doc-self">operator==</a>(</span><span class="m-doc-wrap">const <a href="classtf_1_1Task.html" class="m-doc">Task</a>& rhs) const -> bool</span>
</dt>
<dd>compares if two tasks are associated with the same graph node</dd>
<dt id="af4e13636e3a494297b30c2b2e483f095">
<span class="m-doc-wrap-bumper">auto <a href="#af4e13636e3a494297b30c2b2e483f095" class="m-doc-self">operator!=</a>(</span><span class="m-doc-wrap">const <a href="classtf_1_1Task.html" class="m-doc">Task</a>& rhs) const -> bool</span>
</dt>
<dd>compares if two tasks are not associated with the same graph node</dd>
<dt id="a08ada0425b490997b6ff7f310107e5e3">
<span class="m-doc-wrap-bumper">auto <a href="#a08ada0425b490997b6ff7f310107e5e3" class="m-doc-self">name</a>(</span><span class="m-doc-wrap">) const -> const <a href="http://en.cppreference.com/w/cpp/string/basic_string.html" class="m-doc-external">std::<wbr />string</a>&</span>
</dt>
<dd>queries the name of the task</dd>
<dt id="a1a0afc89e8a6a416c511e74d82df135d">
<span class="m-doc-wrap-bumper">auto <a href="#a1a0afc89e8a6a416c511e74d82df135d" class="m-doc-self">num_successors</a>(</span><span class="m-doc-wrap">) const -> size_t</span>
</dt>
<dd>queries the number of successors of the task</dd>
<dt id="adefb65d68a64bd8a75364a8801cfec44">
<span class="m-doc-wrap-bumper">auto <a href="#adefb65d68a64bd8a75364a8801cfec44" class="m-doc-self">num_predecessors</a>(</span><span class="m-doc-wrap">) const -> size_t</span>
</dt>
<dd>queries the number of predecessors of the task</dd>
<dt id="a0b7b789c9b8a21927a992f6ccc11de81">
<span class="m-doc-wrap-bumper">auto <a href="#a0b7b789c9b8a21927a992f6ccc11de81" class="m-doc-self">num_strong_dependencies</a>(</span><span class="m-doc-wrap">) const -> size_t</span>
</dt>
<dd>queries the number of strong dependents of the task</dd>
<dt id="ad5e874b7cc77df1e7dc875d436ff7b72">
<span class="m-doc-wrap-bumper">auto <a href="#ad5e874b7cc77df1e7dc875d436ff7b72" class="m-doc-self">num_weak_dependencies</a>(</span><span class="m-doc-wrap">) const -> size_t</span>
</dt>
<dd>queries the number of weak dependents of the task</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#a9057ecd0f3833b717480e914f8568f02" class="m-doc">name</a>(</span><span class="m-doc-wrap">const <a href="http://en.cppreference.com/w/cpp/string/basic_string.html" class="m-doc-external">std::<wbr />string</a>& name) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>assigns a name to the task</dd>
<dt>
<div class="m-doc-template">template<typename C></div>
<span class="m-doc-wrap-bumper">auto <a href="#a2f6f4cec42d016e5eb89390f362ffe99" class="m-doc">work</a>(</span><span class="m-doc-wrap">C&& callable) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>assigns a callable</dd>
<dt>
<div class="m-doc-template">template<typename T></div>
<span class="m-doc-wrap-bumper">auto <a href="#ab38be520fe700cb4ca1f312308a95585" class="m-doc">composed_of</a>(</span><span class="m-doc-wrap">T& object) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>creates a module task from a taskflow</dd>
<dt>
<div class="m-doc-template">template<typename... Ts></div>
<span class="m-doc-wrap-bumper">auto <a href="#a8c78c453295a553c1c016e4062da8588" class="m-doc">precede</a>(</span><span class="m-doc-wrap">Ts && ... tasks) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>adds precedence links from this to other tasks</dd>
<dt>
<div class="m-doc-template">template<typename... Ts></div>
<span class="m-doc-wrap-bumper">auto <a href="#a331b1b726555072e7c7d10941257f664" class="m-doc">succeed</a>(</span><span class="m-doc-wrap">Ts && ... tasks) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>adds precedence links from other tasks to this</dd>
<dt id="a26709523eb112f2d024f4c0e9d2f0019">
<span class="m-doc-wrap-bumper">auto <a href="#a26709523eb112f2d024f4c0e9d2f0019" class="m-doc-self">release</a>(</span><span class="m-doc-wrap"><a href="classtf_1_1Semaphore.html" class="m-doc">Semaphore</a>& semaphore) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>makes the task release this semaphore</dd>
<dt id="a1c64e317dba24a8cf4f8da6123bc33af">
<div class="m-doc-template">template<typename I></div>
<span class="m-doc-wrap-bumper">auto <a href="#a1c64e317dba24a8cf4f8da6123bc33af" class="m-doc-self">release</a>(</span><span class="m-doc-wrap">I first,
I last) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>makes the task release the given range of semaphores</dd>
<dt id="a076ab9c6f3a0346e16cfb5fee7dc4ce8">
<span class="m-doc-wrap-bumper">auto <a href="#a076ab9c6f3a0346e16cfb5fee7dc4ce8" class="m-doc-self">acquire</a>(</span><span class="m-doc-wrap"><a href="classtf_1_1Semaphore.html" class="m-doc">Semaphore</a>& semaphore) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>makes the task acquire this semaphore</dd>
<dt id="a39efdef7d401205115d10c3c2e76e456">
<div class="m-doc-template">template<typename I></div>
<span class="m-doc-wrap-bumper">auto <a href="#a39efdef7d401205115d10c3c2e76e456" class="m-doc-self">acquire</a>(</span><span class="m-doc-wrap">I first,
I last) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>makes the task acquire the given range of semaphores</dd>
<dt>
<span class="m-doc-wrap-bumper">auto <a href="#afd82ab6d6518d1142a72c4d2c97ff114" class="m-doc">data</a>(</span><span class="m-doc-wrap">void* data) -> <a href="classtf_1_1Task.html" class="m-doc">Task</a>&</span>
</dt>
<dd>assigns pointer to user data</dd>
<dt id="a302f51ed717d0a4e99edc50f92a571f3">
<span class="m-doc-wrap-bumper">void <a href="#a302f51ed717d0a4e99edc50f92a571f3" class="m-doc-self">reset</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd>resets the task handle to null</dd>
<dt id="aec3ab712e12137542b7e4bc311ee9f20">
<span class="m-doc-wrap-bumper">void <a href="#aec3ab712e12137542b7e4bc311ee9f20" class="m-doc-self">reset_work</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd>resets the associated work to a placeholder</dd>
<dt id="a8149edcf9ec2bfac18dd171f7a55ce06">
<span class="m-doc-wrap-bumper">auto <a href="#a8149edcf9ec2bfac18dd171f7a55ce06" class="m-doc-self">empty</a>(</span><span class="m-doc-wrap">) const -> bool</span>
</dt>
<dd>queries if the task handle points to a task node</dd>
<dt id="afc4ecb89dd4e4645b3ec3fb7c1bb0ec5">
<span class="m-doc-wrap-bumper">auto <a href="#afc4ecb89dd4e4645b3ec3fb7c1bb0ec5" class="m-doc-self">has_work</a>(</span><span class="m-doc-wrap">) const -> bool</span>
</dt>
<dd>queries if the task has a work assigned</dd>
<dt id="aff13a503d4a3c994eb08cb6f22e1b427">
<div class="m-doc-template">template<typename V></div>
<span class="m-doc-wrap-bumper">void <a href="#aff13a503d4a3c994eb08cb6f22e1b427" class="m-doc-self">for_each_successor</a>(</span><span class="m-doc-wrap">V&& visitor) const</span>
</dt>
<dd>applies an visitor callable to each successor of the task</dd>
<dt id="a31d8069d4c0b10b55e68d260c4d28c1f">
<div class="m-doc-template">template<typename V></div>
<span class="m-doc-wrap-bumper">void <a href="#a31d8069d4c0b10b55e68d260c4d28c1f" class="m-doc-self">for_each_predecessor</a>(</span><span class="m-doc-wrap">V&& visitor) const</span>
</dt>
<dd>applies an visitor callable to each dependents of the task</dd>
<dt id="a1c9301f2a330cc23ee18e8f61688141f">
<span class="m-doc-wrap-bumper">auto <a href="#a1c9301f2a330cc23ee18e8f61688141f" class="m-doc-self">hash_value</a>(</span><span class="m-doc-wrap">) const -> size_t</span>
</dt>
<dd>obtains a hash value of the underlying node</dd>
<dt id="af2df95e6c8c5870c033d692e88af0bc2">
<span class="m-doc-wrap-bumper">auto <a href="#af2df95e6c8c5870c033d692e88af0bc2" class="m-doc-self">type</a>(</span><span class="m-doc-wrap">) const -> <a href="namespacetf.html#a1355048578785a80414707ff308b395a" class="m-doc">TaskType</a></span>
</dt>
<dd>returns the task type</dd>
<dt id="a3318a49ff9d0a01cd1e8ee675251e3b7">
<span class="m-doc-wrap-bumper">void <a href="#a3318a49ff9d0a01cd1e8ee675251e3b7" class="m-doc-self">dump</a>(</span><span class="m-doc-wrap"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html" class="m-doc-external">std::<wbr />ostream</a>& ostream) const</span>
</dt>
<dd>dumps the task through an output stream</dd>
<dt id="a320827cb70295a6fe2cc37691405409c">
<span class="m-doc-wrap-bumper">auto <a href="#a320827cb70295a6fe2cc37691405409c" class="m-doc-self">data</a>(</span><span class="m-doc-wrap">) const -> void*</span>
</dt>
<dd>queries pointer to user data</dd>
</dl>
</section>
<section>
<h2>Function documentation</h2>
<section class="m-doc-details" id="a9057ecd0f3833b717480e914f8568f02"><div>
<h3>
<span class="m-doc-wrap-bumper"><a href="classtf_1_1Task.html" class="m-doc">Task</a>& tf::<wbr />Task::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a9057ecd0f3833b717480e914f8568f02" class="m-doc-self">name</a>(</span><span class="m-doc-wrap">const <a href="http://en.cppreference.com/w/cpp/string/basic_string.html" class="m-doc-external">std::<wbr />string</a>& name)</span></span>
</h3>
<p>assigns a name to the task</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">name</td>
<td>a <a href="https://en.cppreference.com/w/cpp/string/basic_string">std::<wbr />string</a> acceptable string</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td><code>*this</code></td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a2f6f4cec42d016e5eb89390f362ffe99"><div>
<h3>
<div class="m-doc-template">
template<typename C>
</div>
<span class="m-doc-wrap-bumper"><a href="classtf_1_1Task.html" class="m-doc">Task</a>& tf::<wbr />Task::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a2f6f4cec42d016e5eb89390f362ffe99" class="m-doc-self">work</a>(</span><span class="m-doc-wrap">C&& callable)</span></span>
</h3>
<p>assigns a callable</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Template parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">C</td>
<td>callable type</td>
</tr>
</tbody>
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td>callable</td>
<td>callable to construct a task</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td><code>*this</code></td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="ab38be520fe700cb4ca1f312308a95585"><div>
<h3>
<div class="m-doc-template">
template<typename T>
</div>
<span class="m-doc-wrap-bumper"><a href="classtf_1_1Task.html" class="m-doc">Task</a>& tf::<wbr />Task::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ab38be520fe700cb4ca1f312308a95585" class="m-doc-self">composed_of</a>(</span><span class="m-doc-wrap">T& object)</span></span>
</h3>
<p>creates a module task from a taskflow</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Template parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">T</td>
<td>object type</td>
</tr>
</tbody>
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td>object</td>
<td>a custom object that defines <code>T::graph()</code> method</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td><code>*this</code></td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a8c78c453295a553c1c016e4062da8588"><div>
<h3>
<div class="m-doc-template">
template<typename... Ts>
</div>
<span class="m-doc-wrap-bumper"><a href="classtf_1_1Task.html" class="m-doc">Task</a>& tf::<wbr />Task::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a8c78c453295a553c1c016e4062da8588" class="m-doc-self">precede</a>(</span><span class="m-doc-wrap">Ts && ... tasks)</span></span>
</h3>
<p>adds precedence links from this to other tasks</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Template parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">Ts</td>
<td>parameter pack</td>
</tr>
</tbody>
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td>tasks</td>
<td>one or multiple tasks</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td><code>*this</code></td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="a331b1b726555072e7c7d10941257f664"><div>
<h3>
<div class="m-doc-template">
template<typename... Ts>
</div>
<span class="m-doc-wrap-bumper"><a href="classtf_1_1Task.html" class="m-doc">Task</a>& tf::<wbr />Task::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a331b1b726555072e7c7d10941257f664" class="m-doc-self">succeed</a>(</span><span class="m-doc-wrap">Ts && ... tasks)</span></span>
</h3>
<p>adds precedence links from other tasks to this</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Template parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">Ts</td>
<td>parameter pack</td>
</tr>
</tbody>
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td>tasks</td>
<td>one or multiple tasks</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td><code>*this</code></td>
</tr>
</tfoot>
</table>
</div></section>
<section class="m-doc-details" id="afd82ab6d6518d1142a72c4d2c97ff114"><div>
<h3>
<span class="m-doc-wrap-bumper"><a href="classtf_1_1Task.html" class="m-doc">Task</a>& tf::<wbr />Task::<wbr /></span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#afd82ab6d6518d1142a72c4d2c97ff114" class="m-doc-self">data</a>(</span><span class="m-doc-wrap">void* data)</span></span>
</h3>
<p>assigns pointer to user data</p>
<table class="m-table m-fullwidth m-flat">
<thead>
<tr><th colspan="2">Parameters</th></tr>
</thead>
<tbody>
<tr>
<td style="width: 1%">data</td>
<td>pointer to user data</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Returns</th>
<td><code>*this</code></td>
</tr>
</tfoot>
</table>
<p>The following example shows how to attach user data to a task and run the task iteratively while changing the data value:</p><pre class="m-code"><span class="n">tf</span><span class="o">::</span><span class="n">Executor</span><span class="w"> </span><span class="n">executor</span><span class="p">;</span>
<span class="n">tf</span><span class="o">::</span><span class="n">Taskflow</span><span class="w"> </span><span class="n">taskflow</span><span class="p">(</span><span class="s">"attach data to a task"</span><span class="p">);</span>
<span class="kt">int</span><span class="w"> </span><span class="n">data</span><span class="p">;</span>
<span class="c1">// create a task and attach it the data</span>
<span class="k">auto</span><span class="w"> </span><span class="n">A</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">taskflow</span><span class="p">.</span><span class="n">placeholder</span><span class="p">();</span>
<span class="n">A</span><span class="p">.</span><span class="n">data</span><span class="p">(</span><span class="o">&</span><span class="n">data</span><span class="p">).</span><span class="n">work</span><span class="p">([</span><span class="n">A</span><span class="p">](){</span>
<span class="w"> </span><span class="k">auto</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">*</span><span class="k">static_cast</span><span class="o"><</span><span class="kt">int</span><span class="o">*></span><span class="p">(</span><span class="n">A</span><span class="p">.</span><span class="n">data</span><span class="p">());</span>
<span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">cout</span><span class="w"> </span><span class="o"><<</span><span class="w"> </span><span class="s">"data is "</span><span class="w"> </span><span class="o"><<</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="o"><<</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
<span class="p">});</span>
<span class="c1">// run the taskflow iteratively with changing data</span>
<span class="k">for</span><span class="p">(</span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">data</span><span class="o"><</span><span class="mi">10</span><span class="p">;</span><span class="w"> </span><span class="n">data</span><span class="o">++</span><span class="p">){</span>
<span class="w"> </span><span class="n">executor</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">taskflow</span><span class="p">).</span><span class="n">wait</span><span class="p">();</span>
<span class="p">}</span></pre>
</div></section>
</section>
</div>
</div>
</div>
</article></main>
<div class="m-doc-search" id="search">
<a href="#!" onclick="return hideSearch()"></a>
<div class="m-container">
<div class="m-row">
<div class="m-col-m-8 m-push-m-2">
<div class="m-doc-search-header m-text m-small">
<div><span class="m-label m-default">Tab</span> / <span class="m-label m-default">T</span> to search, <span class="m-label m-default">Esc</span> to close</div>
<div id="search-symbolcount">…</div>
</div>
<div class="m-doc-search-content">
<form>
<input type="search" name="q" id="search-input" placeholder="Loading …" disabled="disabled" autofocus="autofocus" autocomplete="off" spellcheck="false" />
</form>
<noscript class="m-text m-danger m-text-center">Unlike everything else in the docs, the search functionality <em>requires</em> JavaScript.</noscript>
<div id="search-help" class="m-text m-dim m-text-center">
<p class="m-noindent">Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
<code>:</code> or <code>/</code> suffix lists all members of given symbol or
directory.</p>
<p class="m-noindent">Use <span class="m-label m-dim">↓</span>
/ <span class="m-label m-dim">↑</span> to navigate through the list,
<span class="m-label m-dim">Enter</span> to go.
<span class="m-label m-dim">Tab</span> autocompletes common prefix, you can
copy a link to the result using <span class="m-label m-dim">⌘</span>
<span class="m-label m-dim">L</span> while <span class="m-label m-dim">⌘</span>
<span class="m-label m-dim">M</span> produces a Markdown link.</p>
</div>
<div id="search-notfound" class="m-text m-warning m-text-center">Sorry, nothing was found.</div>
<ul id="search-results"></ul>
</div>
</div>
</div>
</div>
</div>
<script src="search-v2.js"></script>
<script src="searchdata-v2.js" async="async"></script>
<footer><nav>
<div class="m-container">
<div class="m-row">
<div class="m-col-l-10 m-push-l-1">
<p>Taskflow handbook is part of the <a href="https://taskflow.github.io">Taskflow project</a>, copyright © <a href="https://tsung-wei-huang.github.io/">Dr. Tsung-Wei Huang</a>, 2018–2025.<br />Generated by <a href="https://doxygen.org/">Doxygen</a> 1.12.0 and <a href="https://mcss.mosra.cz/">m.css</a>.</p>
</div>
</div>
</div>
</nav></footer>
</body>
</html>