@@ -433,50 +433,62 @@ void swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroup(
433433 const unsigned char *file, uintptr_t fileLength,
434434 bool fileIsASCII, uintptr_t line);
435435
436- // / Get a task local value from the passed in task. Its Swift signature is
436+ // / Get a task local value from either the current task, or fallback task-local
437+ // / storage.
438+ // /
439+ // / Its Swift signature is
437440// /
438441// / \code
439442// / func _taskLocalValueGet<Key>(
440- // / _ task: Builtin.NativeObject,
441443// / keyType: Any.Type /*Key.Type*/
442444// / ) -> UnsafeMutableRawPointer? where Key: TaskLocalKey
443445// / \endcode
444446SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
445447OpaqueValue*
446- swift_task_localValueGet (AsyncTask* task, const HeapObject *key);
448+ swift_task_localValueGet (const HeapObject *key);
447449
448- // / Add a task local value to the passed in task.
449- // /
450- // / This must be only invoked by the task itself to avoid concurrent writes .
450+ // / Bind a task local key to a value in the context of either the current
451+ // / AsyncTask if present, or in the thread-local fallback context if no task
452+ // / available .
451453// /
452454// / Its Swift signature is
453455// /
454456// / \code
455457// / public func _taskLocalValuePush<Value>(
456- // / _ task: Builtin.NativeObject,
457458// / keyType: Any.Type/*Key.Type*/,
458459// / value: __owned Value
459460// / )
460461// / \endcode
461462SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
462- void swift_task_localValuePush (AsyncTask* task,
463- const HeapObject *key,
464- /* +1 */ OpaqueValue *value,
465- const Metadata *valueType);
463+ void swift_task_localValuePush (const HeapObject *key,
464+ /* +1 */ OpaqueValue *value,
465+ const Metadata *valueType);
466466
467- // / Remove task a local binding from the task local values stack.
467+ // / Pop a single task local binding from the binding stack of the current task,
468+ // / or the fallback thread-local storage if no task is available.
468469// /
469- // / This must be only invoked by the task itself to avoid concurrent writes.
470+ // / This operation must be paired up with a preceding "push" operation, as otherwise
471+ // / it may attempt to "pop" off an empty value stuck which will lead to a crash.
472+ // /
473+ // / The Swift surface API ensures proper pairing of push and pop operations.
470474// /
471475// / Its Swift signature is
472476// /
473477// / \code
474- // / public func _taskLocalValuePop(
475- // / _ task: Builtin.NativeObject
476- // / )
478+ // / public func _taskLocalValuePop()
479+ // / \endcode
480+ SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
481+ void swift_task_localValuePop ();
482+
483+ // / Copy all task locals from the current context to the target task.
484+ // /
485+ // / Its Swift signature is
486+ // /
487+ // / \code
488+ // / func _taskLocalValueGet<Key>(AsyncTask* task)
477489// / \endcode
478490SWIFT_EXPORT_FROM (swift_Concurrency) SWIFT_CC(swift)
479- void swift_task_localValuePop (AsyncTask* task );
491+ void swift_task_localsCopyTo (AsyncTask* target );
480492
481493// / This should have the same representation as an enum like this:
482494// / enum NearestTaskDeadline {
0 commit comments