20
20
#include " swift/ABI/TaskGroup.h"
21
21
#include " swift/ABI/TaskStatus.h"
22
22
23
+ #pragma clang diagnostic push
24
+ #pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
25
+
23
26
namespace swift {
24
27
class DefaultActor ;
25
28
@@ -34,7 +37,6 @@ struct AsyncTaskAndContext {
34
37
// / function.
35
38
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
36
39
AsyncTaskAndContext swift_task_create_f (JobFlags flags,
37
- AsyncTask *parent,
38
40
ThinNullaryAsyncSignature::FunctionType *function,
39
41
size_t initialContextSize);
40
42
@@ -47,24 +49,23 @@ using FutureAsyncSignature =
47
49
// / closure.
48
50
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
49
51
AsyncTaskAndContext swift_task_create_future (
50
- JobFlags flags, AsyncTask *parent, const Metadata *futureResultType,
52
+ JobFlags flags, const Metadata *futureResultType,
51
53
void *closureEntryPoint,
52
54
HeapObject * /* +1 */ closureContext);
53
55
54
56
// / Create a task object with a future which will run the given
55
57
// / function.
56
58
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
57
59
AsyncTaskAndContext swift_task_create_future_f (
58
- JobFlags flags, AsyncTask *parent, const Metadata *futureResultType,
60
+ JobFlags flags, const Metadata *futureResultType,
59
61
FutureAsyncSignature::FunctionType *function,
60
62
size_t initialContextSize);
61
63
62
64
// / Create a task object with a future which will run the given
63
65
// / closure, and offer its result to the task group
64
66
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
65
67
AsyncTaskAndContext swift_task_create_group_future (
66
- JobFlags flags,
67
- AsyncTask *parent, TaskGroup *group,
68
+ JobFlags flags, TaskGroup *group,
68
69
const Metadata *futureResultType,
69
70
void *closureEntryPoint,
70
71
HeapObject * /* +1 */ closureContext);
@@ -73,8 +74,7 @@ AsyncTaskAndContext swift_task_create_group_future(
73
74
// / function, and offer its result to the task group
74
75
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
75
76
AsyncTaskAndContext swift_task_create_group_future_f (
76
- JobFlags flags,
77
- AsyncTask *parent, TaskGroup *group,
77
+ JobFlags flags, TaskGroup *group,
78
78
const Metadata *futureResultType,
79
79
FutureAsyncSignature::FunctionType *function,
80
80
size_t initialContextSize);
@@ -85,15 +85,15 @@ AsyncTaskAndContext swift_task_create_group_future_f(
85
85
// /
86
86
// / All allocations will be rounded to a multiple of MAX_ALIGNMENT.
87
87
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
88
- void *swift_task_alloc (AsyncTask *task, size_t size);
88
+ void *swift_task_alloc (size_t size);
89
89
90
90
// / Deallocate memory in a task.
91
91
// /
92
92
// / The pointer provided must be the last pointer allocated on
93
93
// / this task that has not yet been deallocated; that is, memory
94
94
// / must be allocated and deallocated in a strict stack discipline.
95
95
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
96
- void swift_task_dealloc (AsyncTask *task, void *ptr);
96
+ void swift_task_dealloc (void *ptr);
97
97
98
98
// / Cancel a task and all of its child tasks.
99
99
// /
@@ -103,9 +103,9 @@ void swift_task_dealloc(AsyncTask *task, void *ptr);
103
103
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
104
104
void swift_task_cancel (AsyncTask *task);
105
105
106
- // / Cancel all child tasks of `parent` that belong to the `group`.
106
+ // / Cancel all the child tasks that belong to the `group`.
107
107
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
108
- void swift_task_cancel_group_child_tasks (AsyncTask *task, TaskGroup *group);
108
+ void swift_task_cancel_group_child_tasks (TaskGroup *group);
109
109
110
110
// / Escalate the priority of a task and all of its child tasks.
111
111
// /
@@ -170,26 +170,22 @@ swift_taskGroup_wait_next_throwing;
170
170
// / Its Swift signature is
171
171
// /
172
172
// / \code
173
- // / func swift_taskGroup_create(
174
- // / _ task: Builtin.NativeObject
175
- // / ) -> Builtin.RawPointer
173
+ // / func swift_taskGroup_create() -> Builtin.RawPointer
176
174
// / \endcode
177
175
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
178
- TaskGroup* swift_taskGroup_create (AsyncTask *task ); // TODO: probably remove this call, and just use the initialize always
176
+ TaskGroup* swift_taskGroup_create (); // TODO: probably remove this call, and just use the initialize always
179
177
180
178
// / Initialize a `TaskGroup` in the passed `group` memory location.
181
179
// / The caller is responsible for retaining and managing the group's lifecycle.
182
180
// /
183
181
// / Its Swift signature is
184
182
// /
185
183
// / \code
186
- // / func swift_taskGroup_initialize(
187
- // / _ task: Builtin.NativeObject,
188
- // / group: Builtin.RawPointer,
184
+ // / func swift_taskGroup_initialize(group: Builtin.RawPointer
189
185
// / )
190
186
// / \endcode
191
187
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
192
- void swift_taskGroup_initialize (AsyncTask *task, TaskGroup *group);
188
+ void swift_taskGroup_initialize (TaskGroup *group);
193
189
194
190
// / Attach a child task to the parent task's task group record.
195
191
// /
@@ -215,13 +211,10 @@ void swift_taskGroup_attachChild(TaskGroup *group, AsyncTask *child);
215
211
// / This function MUST be called from the AsyncTask running the task group.
216
212
// /
217
213
// / \code
218
- // / func swift_taskGroup_destroy(
219
- // / _ task: Builtin.NativeObject,
220
- // / _ group: UnsafeRawPointer
221
- // / )
214
+ // / func swift_taskGroup_destroy(_ group: UnsafeRawPointer)
222
215
// / \endcode
223
216
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
224
- void swift_taskGroup_destroy (AsyncTask *task, TaskGroup *group);
217
+ void swift_taskGroup_destroy (TaskGroup *group);
225
218
226
219
// / Before starting a task group child task, inform the group that there is one
227
220
// / more 'pending' child to account for.
@@ -247,13 +240,10 @@ bool swift_taskGroup_addPending(TaskGroup *group);
247
240
// / Its Swift signature is
248
241
// /
249
242
// / \code
250
- // / func swift_taskGroup_cancelAll(
251
- // / task: Builtin.NativeObject,
252
- // / group: UnsafeRawPointer
253
- // / )
243
+ // / func swift_taskGroup_cancelAll(group: UnsafeRawPointer)
254
244
// / \endcode
255
245
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
256
- void swift_taskGroup_cancelAll (AsyncTask *task, TaskGroup *group);
246
+ void swift_taskGroup_cancelAll (TaskGroup *group);
257
247
258
248
// / Check ONLY if the group was explicitly cancelled, e.g. by `cancelAll`.
259
249
// /
@@ -263,13 +253,10 @@ void swift_taskGroup_cancelAll(AsyncTask *task, TaskGroup *group);
263
253
// / This can be called from any thread. Its Swift signature is
264
254
// /
265
255
// / \code
266
- // / func swift_taskGroup_isCancelled(
267
- // / task: Builtin.NativeObject,
268
- // / group: UnsafeRawPointer
269
- // / )
256
+ // / func swift_taskGroup_isCancelled(group: UnsafeRawPointer)
270
257
// / \endcode
271
258
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
272
- bool swift_taskGroup_isCancelled (AsyncTask *task, TaskGroup *group);
259
+ bool swift_taskGroup_isCancelled (TaskGroup *group);
273
260
274
261
// / Check the readyQueue of a task group, return true if it has no pending tasks.
275
262
// /
@@ -291,8 +278,7 @@ bool swift_taskGroup_isEmpty(TaskGroup *group);
291
278
// / If the task is already cancelled, returns `false` but still adds
292
279
// / the status record.
293
280
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
294
- bool swift_task_addStatusRecord (AsyncTask *task,
295
- TaskStatusRecord *record);
281
+ bool swift_task_addStatusRecord (TaskStatusRecord *record);
296
282
297
283
// / Add a status record to a task if the task has not already
298
284
// / been cancelled. The record should not be modified while it is
@@ -303,8 +289,7 @@ bool swift_task_addStatusRecord(AsyncTask *task,
303
289
// / If the task is already cancelled, returns `false` and does not
304
290
// / add the status record.
305
291
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
306
- bool swift_task_tryAddStatusRecord (AsyncTask *task,
307
- TaskStatusRecord *record);
292
+ bool swift_task_tryAddStatusRecord (TaskStatusRecord *record);
308
293
309
294
// / Remove a status record from a task. After this call returns,
310
295
// / the record's memory can be freely modified or deallocated.
@@ -317,7 +302,7 @@ bool swift_task_tryAddStatusRecord(AsyncTask *task,
317
302
// /s
318
303
// / Returns false if the task has been cancelled.
319
304
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
320
- bool swift_task_removeStatusRecord (AsyncTask *task, TaskStatusRecord *record);
305
+ bool swift_task_removeStatusRecord (TaskStatusRecord *record);
321
306
322
307
// / Attach a child task to its parent task and return the newly created
323
308
// / `ChildTaskStatusRecord`.
@@ -326,11 +311,11 @@ bool swift_task_removeStatusRecord(AsyncTask *task, TaskStatusRecord *record);
326
311
// / `swift_task_detachChild` when the child has completed.
327
312
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
328
313
ChildTaskStatusRecord*
329
- swift_task_attachChild (AsyncTask *parent, AsyncTask * child);
314
+ swift_task_attachChild (AsyncTask *child);
330
315
331
316
// / Remove a child task from the parent tracking it.
332
317
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
333
- void swift_task_detachChild (AsyncTask *parent, ChildTaskStatusRecord *record);
318
+ void swift_task_detachChild (ChildTaskStatusRecord *record);
334
319
335
320
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
336
321
size_t swift_task_getJobFlags (AsyncTask* task);
@@ -342,12 +327,12 @@ bool swift_task_isCancelled(AsyncTask* task);
342
327
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
343
328
CancellationNotificationStatusRecord*
344
329
swift_task_addCancellationHandler (
345
- AsyncTask *task, CancellationNotificationStatusRecord::FunctionType handler);
330
+ CancellationNotificationStatusRecord::FunctionType handler);
346
331
347
332
// / Remove the passed cancellation record from the task.
348
333
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
349
334
void swift_task_removeCancellationHandler (
350
- AsyncTask *task, CancellationNotificationStatusRecord *record);
335
+ CancellationNotificationStatusRecord *record);
351
336
352
337
// / Get a task local value from the passed in task. Its Swift signature is
353
338
// /
@@ -446,8 +431,8 @@ void swift_task_runAndBlockThread(const void *function,
446
431
// / generally be tail-called, as it may continue executing the task
447
432
// / synchronously if possible.
448
433
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swiftasync)
449
- void swift_task_switch (AsyncTask *task ,
450
- ExecutorRef currentExecutor ,
434
+ void swift_task_switch (SWIFT_ASYNC_CONTEXT AsyncContext *resumeToContext ,
435
+ TaskContinuationFunction *resumeFunction ,
451
436
ExecutorRef newExecutor);
452
437
453
438
// / Enqueue the given job to run asynchronously on the given executor.
@@ -552,6 +537,12 @@ void swift_job_run(Job *job, ExecutorRef executor);
552
537
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
553
538
AsyncTask *swift_task_getCurrent (void );
554
539
540
+ // / Return the current thread's active executor reference.
541
+ SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
542
+ ExecutorRef swift_task_getCurrentExecutor (void );
543
+
555
544
}
556
545
546
+ #pragma clang diagnostic pop
547
+
557
548
#endif
0 commit comments