mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Clean up the TaskGroup ABI:
- stop storing the parent task in the TaskGroup at the .swift level - make sure that swift_taskGroup_isCancelled is implied by the parent task being cancelled - make the TaskGroup structs frozen - make the withTaskGroup functions inlinable - remove swift_taskGroup_create - teach IRGen to allocate memory for the task group - don't deallocate the task group in swift_taskGroup_destroy To achieve the allocation change, introduce paired create/destroy builtins. Furthermore, remove the _swiftRetain and _swiftRelease functions and several calls to them. Replace them with uses of the appropriate builtins. I should probably change the builtins to return retained, since they're working with a managed type, but I'll do that in a separate commit.
This commit is contained in:
@@ -470,18 +470,11 @@ static void swift_taskGroup_initializeImpl(TaskGroup *group) {
|
||||
assert(impl == record && "the group IS the task record");
|
||||
|
||||
// ok, now that the group actually is initialized: attach it to the task
|
||||
swift_task_addStatusRecord(record);
|
||||
}
|
||||
bool notCancelled = swift_task_addStatusRecord(record);
|
||||
|
||||
// =============================================================================
|
||||
// ==== create -----------------------------------------------------------------
|
||||
SWIFT_CC(swift)
|
||||
static TaskGroup *swift_taskGroup_createImpl() {
|
||||
// TODO: John suggested we should rather create from a builtin, which would allow us to optimize allocations even more?
|
||||
void *allocation = swift_task_alloc(sizeof(TaskGroup));
|
||||
auto group = reinterpret_cast<TaskGroup *>(allocation);
|
||||
swift_taskGroup_initialize(group);
|
||||
return group;
|
||||
// If the task has already been cancelled, reflect that immediately in
|
||||
// the group status.
|
||||
if (!notCancelled) impl->statusCancel();
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
@@ -514,9 +507,6 @@ void TaskGroupImpl::destroy() {
|
||||
taskDequeued = readyQueue.dequeue(item);
|
||||
}
|
||||
mutex.unlock(); // TODO: remove fragment lock, and use status for synchronization
|
||||
|
||||
// TODO: get the parent task, do we need to store it?
|
||||
swift_task_dealloc(this);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user