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 @@ -450,10 +450,20 @@ static AsyncTaskAndContext swift_task_create_commonImpl(
450450 if (jobFlags.task_isChildTask ()) {
451451 parent = swift_task_getCurrent ();
452452 assert (parent != nullptr && " creating a child task with no active task" );
453+ }
453454
454- // Inherit the priority of the parent task if unspecified.
455- if (jobFlags.getPriority () == JobPriority::Unspecified)
456- jobFlags.setPriority (parent->getPriority ());
455+ // Inherit the priority of the currently-executing task if unspecified and
456+ // we want to inherit.
457+ if (jobFlags.getPriority () == JobPriority::Unspecified &&
458+ (jobFlags.task_isChildTask () || taskCreateFlags.inheritContext ())) {
459+ AsyncTask *currentTask = parent;
460+ if (!currentTask)
461+ currentTask = swift_task_getCurrent ();
462+
463+ if (currentTask)
464+ jobFlags.setPriority (currentTask->getPriority ());
465+ else
466+ jobFlags.setPriority (swift_task_getCurrentThreadPriority ());
457467 }
458468
459469 // Figure out the size of the header.
You can’t perform that action at this time.
0 commit comments