File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -445,10 +445,20 @@ static AsyncTaskAndContext swift_task_create_commonImpl(
445
445
if (jobFlags.task_isChildTask ()) {
446
446
parent = swift_task_getCurrent ();
447
447
assert (parent != nullptr && " creating a child task with no active task" );
448
+ }
448
449
449
- // Inherit the priority of the parent task if unspecified.
450
- if (jobFlags.getPriority () == JobPriority::Unspecified)
451
- jobFlags.setPriority (parent->getPriority ());
450
+ // Inherit the priority of the currently-executing task if unspecified and
451
+ // we want to inherit.
452
+ if (jobFlags.getPriority () == JobPriority::Unspecified &&
453
+ (jobFlags.task_isChildTask () || taskCreateFlags.inheritContext ())) {
454
+ AsyncTask *currentTask = parent;
455
+ if (!currentTask)
456
+ currentTask = swift_task_getCurrent ();
457
+
458
+ if (currentTask)
459
+ jobFlags.setPriority (currentTask->getPriority ());
460
+ else
461
+ jobFlags.setPriority (swift_task_getCurrentThreadPriority ());
452
462
}
453
463
454
464
// Figure out the size of the header.
You can’t perform that action at this time.
0 commit comments