@@ -413,7 +413,7 @@ static void completeTaskWithClosure(SWIFT_ASYNC_CONTEXT AsyncContext *context,
413
413
reinterpret_cast <char *>(context) - sizeof (AsyncContextPrefix));
414
414
415
415
swift_release ((HeapObject *)asyncContextPrefix->closureContext );
416
-
416
+
417
417
// Clean up the rest of the task.
418
418
return completeTaskAndRelease (context, error);
419
419
}
@@ -470,6 +470,13 @@ const void *AsyncTask::getResumeFunctionForLogging() {
470
470
return reinterpret_cast <const void *>(ResumeTask);
471
471
}
472
472
473
+ JobPriority swift::swift_task_currentPriority (AsyncTask *task)
474
+ {
475
+ // This is racey but this is to be used in an API is inherently racey anyways.
476
+ auto oldStatus = task->_private ().Status .load (std::memory_order_relaxed);
477
+ return oldStatus.getStoredPriority ();
478
+ }
479
+
473
480
// / Implementation of task creation.
474
481
SWIFT_CC (swift)
475
482
static AsyncTaskAndContext swift_task_create_commonImpl(
@@ -520,7 +527,7 @@ static AsyncTaskAndContext swift_task_create_commonImpl(
520
527
// of in a FutureFragment.
521
528
hasAsyncLetResultBuffer = true ;
522
529
assert (asyncLet && " Missing async let storage" );
523
-
530
+
524
531
jobFlags.task_setIsAsyncLetTask (true );
525
532
jobFlags.task_setIsChildTask (true );
526
533
break ;
@@ -591,14 +598,14 @@ static AsyncTaskAndContext swift_task_create_commonImpl(
591
598
void *allocation = nullptr ;
592
599
if (asyncLet) {
593
600
assert (parent);
594
-
601
+
595
602
// If there isn't enough room in the fixed async let allocation to
596
603
// set up the initial context, then we'll have to allocate more space
597
604
// from the parent.
598
605
if (asyncLet->getSizeOfPreallocatedSpace () < amountToAllocate) {
599
606
hasAsyncLetResultBuffer = false ;
600
607
}
601
-
608
+
602
609
// DEPRECATED. This is separated from the above condition because we
603
610
// also have to handle an older async let ABI that did not provide
604
611
// space for the initial slab in the compiler-generated preallocation.
@@ -678,7 +685,7 @@ static AsyncTaskAndContext swift_task_create_commonImpl(
678
685
auto groupChildFragment = task->groupChildFragment ();
679
686
new (groupChildFragment) AsyncTask::GroupChildFragment (group);
680
687
}
681
-
688
+
682
689
// Initialize the future fragment if applicable.
683
690
if (futureResultType) {
684
691
assert (task->isFuture ());
@@ -940,7 +947,7 @@ static AsyncTask *swift_continuation_initImpl(ContinuationAsyncContext *context,
940
947
// must happen-after this call.
941
948
context->AwaitSynchronization .store (flags.isPreawaited ()
942
949
? ContinuationStatus::Awaited
943
- : ContinuationStatus::Pending,
950
+ : ContinuationStatus::Pending,
944
951
std::memory_order_relaxed);
945
952
946
953
AsyncTask *task;
0 commit comments