@@ -70,30 +70,41 @@ struct AsyncTaskAndContext {
70
70
AsyncContext *InitialContext;
71
71
};
72
72
73
+ SWIFT_BEGIN_DECLS
74
+
73
75
// / Create a task object.
74
76
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
75
- AsyncTaskAndContext swift_task_create (
76
- size_t taskCreateFlags,
77
- TaskOptionRecord *options,
78
- const Metadata *futureResultType,
79
- void *closureEntry, HeapObject *closureContext);
77
+ AsyncTaskAndContext swift_task_create (size_t taskCreateFlags,
78
+ TaskOptionRecord *options,
79
+ const Metadata *futureResultType,
80
+ void *closureEntry,
81
+ HeapObject *closureContext);
82
+
83
+ SWIFT_END_DECLS
80
84
81
85
// / Caution: not all future-initializing functions actually throw, so
82
86
// / this signature may be incorrect.
83
87
using FutureAsyncSignature =
84
88
AsyncSignature<void (void *), /* throws*/ true >;
85
89
90
+ SWIFT_BEGIN_DECLS
91
+
86
92
// / Create a task object.
87
93
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
88
- AsyncTaskAndContext swift_task_create_common (
89
- size_t taskCreateFlags,
90
- TaskOptionRecord *options,
91
- const Metadata *futureResultType,
92
- TaskContinuationFunction *function, void *closureContext,
93
- size_t initialContextSize);
94
+ AsyncTaskAndContext
95
+ swift_task_create_common (size_t taskCreateFlags, TaskOptionRecord *options,
96
+ const Metadata *futureResultType,
97
+ TaskContinuationFunction *function,
98
+ void *closureContext,
99
+ size_t initialContextSize);
100
+
101
+ SWIFT_END_DECLS
94
102
95
103
#if SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL
96
104
#define SWIFT_TASK_RUN_INLINE_INITIAL_CONTEXT_BYTES 4096
105
+
106
+ SWIFT_BEGIN_DECLS
107
+
97
108
// / Begin an async context in the current sync context and run the indicated
98
109
// / closure in it.
99
110
// /
@@ -104,8 +115,13 @@ SWIFT_CC(swift)
104
115
void swift_task_run_inline(OpaqueValue *result, void *closureAFP,
105
116
OpaqueValue *closureContext,
106
117
const Metadata *futureResultType);
118
+
119
+ SWIFT_END_DECLS
120
+
107
121
#endif
108
122
123
+ SWIFT_BEGIN_DECLS
124
+
109
125
// / Allocate memory in a task.
110
126
// /
111
127
// / This must be called synchronously with the task.
@@ -141,8 +157,7 @@ void swift_task_cancel_group_child_tasks(TaskGroup *group);
141
157
// / This has no effect if the task already has at least the given priority.
142
158
// / Returns the priority of the task.
143
159
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
144
- JobPriority
145
- swift_task_escalate (AsyncTask *task, JobPriority newPriority);
160
+ JobPriority swift_task_escalate (AsyncTask *task, JobPriority newPriority);
146
161
147
162
// TODO: "async let wait" and "async let destroy" would be expressed
148
163
// similar to like TaskFutureWait;
@@ -156,10 +171,9 @@ swift_task_escalate(AsyncTask *task, JobPriority newPriority);
156
171
// / -> Success
157
172
// / \endcode
158
173
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swiftasync)
159
- void swift_task_future_wait (OpaqueValue *,
160
- SWIFT_ASYNC_CONTEXT AsyncContext *, AsyncTask *,
161
- TaskContinuationFunction *,
162
- AsyncContext *);
174
+ void
175
+ swift_task_future_wait (OpaqueValue *, SWIFT_ASYNC_CONTEXT AsyncContext *,
176
+ AsyncTask *, TaskContinuationFunction *, AsyncContext *);
163
177
164
178
// / Wait for a potentially-throwing future task to complete.
165
179
// /
@@ -170,12 +184,12 @@ void swift_task_future_wait(OpaqueValue *,
170
184
// / async throws -> Success
171
185
// / \endcode
172
186
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swiftasync)
173
- void swift_task_future_wait_throwing (
174
- OpaqueValue *,
175
- SWIFT_ASYNC_CONTEXT AsyncContext *,
176
- AsyncTask *,
177
- ThrowingTaskFutureWaitContinuationFunction *,
178
- AsyncContext *);
187
+ void
188
+ swift_task_future_wait_throwing ( OpaqueValue *,
189
+ SWIFT_ASYNC_CONTEXT AsyncContext *,
190
+ AsyncTask *,
191
+ ThrowingTaskFutureWaitContinuationFunction *,
192
+ AsyncContext *);
179
193
180
194
// / Wait for a readyQueue of a Channel to become non empty.
181
195
// /
@@ -187,12 +201,13 @@ void swift_task_future_wait_throwing(
187
201
// / group: Builtin.RawPointer
188
202
// / ) async -> T
189
203
// / \endcode
190
- SWIFT_EXPORT_FROM (swift_Concurrency)
191
- SWIFT_CC (swiftasync)
192
- void swift_taskGroup_wait_next_throwing (
193
- OpaqueValue *resultPointer, SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
194
- TaskGroup *group, ThrowingTaskFutureWaitContinuationFunction *resumeFn,
195
- AsyncContext *callContext);
204
+ SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swiftasync)
205
+ void
206
+ swift_taskGroup_wait_next_throwing (OpaqueValue *resultPointer,
207
+ SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
208
+ TaskGroup *group,
209
+ ThrowingTaskFutureWaitContinuationFunction *resumeFn,
210
+ AsyncContext *callContext);
196
211
197
212
// / Initialize a `TaskGroup` in the passed `group` memory location.
198
213
// / The caller is responsible for retaining and managing the group's lifecycle.
@@ -322,12 +337,16 @@ void swift_asyncLet_begin(AsyncLet *alet,
322
337
void *closureEntryPoint, HeapObject *closureContext,
323
338
void *resultBuffer);
324
339
340
+ SWIFT_END_DECLS
341
+
325
342
// / This matches the ABI of a closure `<T>(Builtin.RawPointer) async -> T`
326
343
using AsyncLetWaitSignature =
327
344
SWIFT_CC (swiftasync)
328
345
void (OpaqueValue *,
329
346
SWIFT_ASYNC_CONTEXT AsyncContext *, AsyncTask *, Metadata *);
330
347
348
+ SWIFT_BEGIN_DECLS
349
+
331
350
// / DEPRECATED. swift_asyncLet_get is used instead.
332
351
// / Wait for a non-throwing async-let to complete.
333
352
// /
@@ -608,6 +627,8 @@ void swift_task_localValuePop();
608
627
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
609
628
void swift_task_localsCopyTo (AsyncTask* target);
610
629
630
+ SWIFT_END_DECLS
631
+
611
632
// / This should have the same representation as an enum like this:
612
633
// / enum NearestTaskDeadline {
613
634
// / case none
@@ -626,12 +647,13 @@ struct NearestTaskDeadline {
626
647
Kind ValueKind;
627
648
};
628
649
650
+ SWIFT_BEGIN_DECLS
651
+
629
652
// / Returns the nearest deadline that's been registered with this task.
630
653
// /
631
654
// / This must be called synchronously with the task.
632
655
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
633
- NearestTaskDeadline
634
- swift_task_getNearestDeadline (AsyncTask *task);
656
+ NearestTaskDeadline swift_task_getNearestDeadline (AsyncTask *task);
635
657
636
658
// / Switch the current task to a new executor if we aren't already
637
659
// / running on a compatible executor.
@@ -680,9 +702,13 @@ void swift_task_enqueue(Job *job, ExecutorRef executor);
680
702
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
681
703
void swift_task_enqueueGlobal (Job *job);
682
704
705
+ SWIFT_END_DECLS
706
+
683
707
// / A count in nanoseconds.
684
708
using JobDelay = unsigned long long ;
685
709
710
+ SWIFT_BEGIN_DECLS
711
+
686
712
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
687
713
void swift_task_enqueueGlobalWithDelay (JobDelay delay, Job *job);
688
714
@@ -694,48 +720,72 @@ void swift_task_enqueueGlobalWithDeadline(long long sec, long long nsec,
694
720
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
695
721
void swift_task_enqueueMainExecutor (Job *job);
696
722
723
+ SWIFT_END_DECLS
724
+
697
725
#if SWIFT_CONCURRENCY_ENABLE_DISPATCH
698
726
727
+ SWIFT_BEGIN_DECLS
728
+
699
729
// / Enqueue the given job on the main executor.
700
730
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
701
731
void swift_task_enqueueOnDispatchQueue(Job *job, HeapObject *queue);
702
732
733
+ SWIFT_END_DECLS
734
+
703
735
#endif
704
736
705
737
// / A hook to take over global enqueuing.
706
738
typedef SWIFT_CC (swift) void (*swift_task_enqueueGlobal_original)(Job *job);
707
- SWIFT_EXPORT_FROM (swift_Concurrency)
708
- SWIFT_CC (swift) void (*swift_task_enqueueGlobal_hook)(
739
+
740
+ SWIFT_BEGIN_DECLS
741
+
742
+ SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
743
+ extern void (*swift_task_enqueueGlobal_hook)(
709
744
Job *job, swift_task_enqueueGlobal_original original);
710
745
746
+ SWIFT_END_DECLS
747
+
711
748
// / A hook to take over global enqueuing with delay.
712
749
typedef SWIFT_CC (swift) void (*swift_task_enqueueGlobalWithDelay_original)(
713
750
unsigned long long delay, Job *job);
714
- SWIFT_EXPORT_FROM (swift_Concurrency)
715
- SWIFT_CC (swift) void (*swift_task_enqueueGlobalWithDelay_hook)(
751
+
752
+ SWIFT_BEGIN_DECLS
753
+
754
+ SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
755
+ extern void (*swift_task_enqueueGlobalWithDelay_hook)(
716
756
unsigned long long delay, Job *job,
717
757
swift_task_enqueueGlobalWithDelay_original original);
718
758
759
+ SWIFT_END_DECLS
760
+
719
761
typedef SWIFT_CC (swift) void (*swift_task_enqueueGlobalWithDeadline_original)(
720
762
long long sec,
721
763
long long nsec,
722
764
long long tsec,
723
765
long long tnsec,
724
766
int clock, Job *job);
725
- SWIFT_EXPORT_FROM (swift_Concurrency)
726
- SWIFT_CC (swift) void (*swift_task_enqueueGlobalWithDeadline_hook)(
767
+
768
+ SWIFT_BEGIN_DECLS
769
+
770
+ SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
771
+ extern void (*swift_task_enqueueGlobalWithDeadline_hook)(
727
772
long long sec,
728
773
long long nsec,
729
774
long long tsec,
730
775
long long tnsec,
731
776
int clock, Job *job,
732
777
swift_task_enqueueGlobalWithDeadline_original original);
733
778
779
+ SWIFT_END_DECLS
780
+
734
781
// / A hook to take over main executor enqueueing.
735
782
typedef SWIFT_CC (swift) void (*swift_task_enqueueMainExecutor_original)(
736
783
Job *job);
737
- SWIFT_EXPORT_FROM (swift_Concurrency)
738
- SWIFT_CC (swift) void (*swift_task_enqueueMainExecutor_hook)(
784
+
785
+ SWIFT_BEGIN_DECLS
786
+
787
+ SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
788
+ extern void (*swift_task_enqueueMainExecutor_hook)(
739
789
Job *job, swift_task_enqueueMainExecutor_original original);
740
790
741
791
// / Initialize the runtime storage for a default actor.
@@ -756,8 +806,7 @@ void swift_defaultActor_deallocateResilient(HeapObject *actor);
756
806
757
807
// / Initialize the runtime storage for a distributed remote actor.
758
808
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
759
- OpaqueValue*
760
- swift_distributedActor_remote_initialize (const Metadata *actorType);
809
+ OpaqueValue* swift_distributedActor_remote_initialize (const Metadata *actorType);
761
810
762
811
// / Enqueue a job on the default actor implementation.
763
812
// /
@@ -817,7 +866,7 @@ void swift_continuation_throwingResumeWithError(AsyncTask *continuation,
817
866
/* +1 */ SwiftError *error);
818
867
819
868
// / SPI helper to log a misuse of a `CheckedContinuation` to the appropriate places in the OS.
820
- extern " C " SWIFT_CC(swift)
869
+ SWIFT_CC (swift)
821
870
void swift_continuation_logFailedCheck (const char *message);
822
871
823
872
// / Drain the queue
@@ -854,15 +903,21 @@ void swift_task_reportUnexpectedExecutor(
854
903
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
855
904
JobPriority swift_task_getCurrentThreadPriority (void );
856
905
906
+ SWIFT_END_DECLS
907
+
857
908
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
858
909
910
+ SWIFT_BEGIN_DECLS
911
+
859
912
// / Donate this thread to the global executor until either the
860
913
// / given condition returns true or we've run out of cooperative
861
914
// / tasks to run.
862
915
SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
863
916
void swift_task_donateThreadToGlobalExecutorUntil(bool (*condition)(void *),
864
917
void *context);
865
918
919
+ SWIFT_END_DECLS
920
+
866
921
#endif
867
922
868
923
enum swift_clock_id : int {
0 commit comments