Skip to content

Commit 074bb55

Browse files
committed
[Concurrency] Drop the cloned code for Embedded around 'any actor'
1 parent f787e8f commit 074bb55

File tree

3 files changed

+1
-289
lines changed

3 files changed

+1
-289
lines changed

stdlib/public/Concurrency/DiscardingTaskGroup.swift

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -184,159 +184,6 @@ public struct DiscardingTaskGroup {
184184
let _: Void? = try await _taskGroupWaitAll(group: _group, bodyError: nil)
185185
}
186186

187-
// Clone the task-creation routines in Embedded Swift so that we don't
188-
// introduce an implicit use of `any Actor`.
189-
#if !$Embedded
190-
191-
/// Adds a child task to the group.
192-
///
193-
/// - Parameters:
194-
/// - priority: The priority of the operation task.
195-
/// Omit this parameter or pass `.unspecified`
196-
/// to set the child task's priority to the priority of the group.
197-
/// - operation: The operation to execute as part of the task group.
198-
@_alwaysEmitIntoClient
199-
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
200-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model", renamed: "addTask(operation:)")
201-
#endif
202-
public mutating func addTask(
203-
priority: TaskPriority? = nil,
204-
operation: sending @escaping @isolated(any) () async -> Void
205-
) {
206-
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
207-
let flags = taskCreateFlags(
208-
priority: priority, isChildTask: true, copyTaskLocals: false,
209-
inheritContext: false, enqueueJob: false,
210-
addPendingGroupTaskUnconditionally: true, isDiscardingTask: true
211-
)
212-
#else
213-
let flags = taskCreateFlags(
214-
priority: priority, isChildTask: true, copyTaskLocals: false,
215-
inheritContext: false, enqueueJob: true,
216-
addPendingGroupTaskUnconditionally: true, isDiscardingTask: true
217-
)
218-
#endif
219-
220-
// Create the task in this group.
221-
let builtinSerialExecutor =
222-
Builtin.extractFunctionIsolation(operation)?.unownedExecutor.executor
223-
224-
_ = Builtin.createDiscardingTask(flags: flags,
225-
initialSerialExecutor: builtinSerialExecutor,
226-
taskGroup: _group,
227-
operation: operation)
228-
}
229-
230-
/// Adds a child task to the group, unless the group has been canceled.
231-
///
232-
/// - Parameters:
233-
/// - priority: The priority of the operation task.
234-
/// Omit this parameter or pass `.unspecified`
235-
/// to set the child task's priority to the priority of the group.
236-
/// - operation: The operation to execute as part of the task group.
237-
/// - Returns: `true` if the child task was added to the group;
238-
/// otherwise `false`.
239-
@_alwaysEmitIntoClient
240-
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
241-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model", renamed: "addTask(operation:)")
242-
#endif
243-
public mutating func addTaskUnlessCancelled(
244-
priority: TaskPriority? = nil,
245-
operation: sending @escaping @isolated(any) () async -> Void
246-
) -> Bool {
247-
let canAdd = _taskGroupAddPendingTask(group: _group, unconditionally: false)
248-
249-
guard canAdd else {
250-
// the group is cancelled and is not accepting any new work
251-
return false
252-
}
253-
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
254-
let flags = taskCreateFlags(
255-
priority: priority, isChildTask: true, copyTaskLocals: false,
256-
inheritContext: false, enqueueJob: false,
257-
addPendingGroupTaskUnconditionally: false, isDiscardingTask: true
258-
)
259-
#else
260-
let flags = taskCreateFlags(
261-
priority: priority, isChildTask: true, copyTaskLocals: false,
262-
inheritContext: false, enqueueJob: true,
263-
addPendingGroupTaskUnconditionally: false, isDiscardingTask: true
264-
)
265-
#endif
266-
267-
// Create the task in this group.
268-
let builtinSerialExecutor =
269-
Builtin.extractFunctionIsolation(operation)?.unownedExecutor.executor
270-
271-
_ = Builtin.createDiscardingTask(flags: flags,
272-
initialSerialExecutor: builtinSerialExecutor,
273-
taskGroup: _group,
274-
operation: operation)
275-
276-
return true
277-
}
278-
279-
@_alwaysEmitIntoClient
280-
public mutating func addTask(
281-
operation: sending @escaping @isolated(any) () async -> Void
282-
) {
283-
let flags = taskCreateFlags(
284-
priority: nil, isChildTask: true, copyTaskLocals: false,
285-
inheritContext: false, enqueueJob: true,
286-
addPendingGroupTaskUnconditionally: true, isDiscardingTask: true
287-
)
288-
289-
// Create the task in this group.
290-
let builtinSerialExecutor =
291-
Builtin.extractFunctionIsolation(operation)?.unownedExecutor.executor
292-
293-
_ = Builtin.createDiscardingTask(flags: flags,
294-
initialSerialExecutor: builtinSerialExecutor,
295-
taskGroup: _group,
296-
operation: operation)
297-
}
298-
299-
/// Adds a child task to the group, unless the group has been canceled.
300-
///
301-
/// - Parameters:
302-
/// - operation: The operation to execute as part of the task group.
303-
/// - Returns: `true` if the child task was added to the group;
304-
/// otherwise `false`.
305-
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
306-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model", renamed: "addTaskUnlessCancelled(operation:)")
307-
#endif
308-
@_alwaysEmitIntoClient
309-
public mutating func addTaskUnlessCancelled(
310-
operation: sending @escaping @isolated(any) () async -> Void
311-
) -> Bool {
312-
let canAdd = _taskGroupAddPendingTask(group: _group, unconditionally: false)
313-
314-
guard canAdd else {
315-
// the group is cancelled and is not accepting any new work
316-
return false
317-
}
318-
319-
let flags = taskCreateFlags(
320-
priority: nil, isChildTask: true, copyTaskLocals: false,
321-
inheritContext: false, enqueueJob: true,
322-
addPendingGroupTaskUnconditionally: false, isDiscardingTask: true
323-
)
324-
325-
// Create the task in this group.
326-
let builtinSerialExecutor =
327-
Builtin.extractFunctionIsolation(operation)?.unownedExecutor.executor
328-
329-
_ = Builtin.createDiscardingTask(flags: flags,
330-
initialSerialExecutor: builtinSerialExecutor,
331-
taskGroup: _group,
332-
operation: operation)
333-
334-
return true
335-
}
336-
337-
// The Embedded clones of the task-creation routines.
338-
#else
339-
340187
/// Adds a child task to the group.
341188
///
342189
/// - Parameters:
@@ -459,8 +306,6 @@ public struct DiscardingTaskGroup {
459306
return true
460307
}
461308

462-
#endif // $Embedded
463-
464309
/// A Boolean value that indicates whether the group has any remaining tasks.
465310
///
466311
/// At the start of the body of a `withDiscardingTaskGroup(of:returning:body:)` call,

stdlib/public/Concurrency/Task.swift

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -635,25 +635,6 @@ extension Task where Failure == Never {
635635
) {
636636
fatalError("Unavailable in task-to-thread concurrency model.")
637637
}
638-
#elseif $Embedded
639-
@discardableResult
640-
@_alwaysEmitIntoClient
641-
public init(
642-
priority: TaskPriority? = nil,
643-
@_inheritActorContext @_implicitSelfCapture operation: sending @escaping () async -> Success
644-
) {
645-
// Set up the job flags for a new task.
646-
let flags = taskCreateFlags(
647-
priority: priority, isChildTask: false, copyTaskLocals: true,
648-
inheritContext: true, enqueueJob: true,
649-
addPendingGroupTaskUnconditionally: false,
650-
isDiscardingTask: false)
651-
652-
// Create the asynchronous task.
653-
let (task, _) = Builtin.createAsyncTask(flags, operation)
654-
655-
self._task = task
656-
}
657638
#else
658639
/// Runs the given nonthrowing operation asynchronously
659640
/// as part of a new top-level task on behalf of the current actor.
@@ -717,25 +698,6 @@ extension Task where Failure == Error {
717698
) {
718699
fatalError("Unavailable in task-to-thread concurrency model")
719700
}
720-
#elseif $Embedded
721-
@discardableResult
722-
@_alwaysEmitIntoClient
723-
public init(
724-
priority: TaskPriority? = nil,
725-
@_inheritActorContext @_implicitSelfCapture operation: sending @escaping () async throws -> Success
726-
) {
727-
// Set up the task flags for a new task.
728-
let flags = taskCreateFlags(
729-
priority: priority, isChildTask: false, copyTaskLocals: true,
730-
inheritContext: true, enqueueJob: true,
731-
addPendingGroupTaskUnconditionally: false,
732-
isDiscardingTask: false)
733-
734-
// Create the asynchronous task future.
735-
let (task, _) = Builtin.createAsyncTask(flags, operation)
736-
737-
self._task = task
738-
}
739701
#else
740702
/// Runs the given throwing operation asynchronously
741703
/// as part of a new top-level task on behalf of the current actor.
@@ -801,25 +763,6 @@ extension Task where Failure == Never {
801763
) -> Task<Success, Failure> {
802764
fatalError("Unavailable in task-to-thread concurrency model")
803765
}
804-
#elseif $Embedded
805-
@discardableResult
806-
@_alwaysEmitIntoClient
807-
public static func detached(
808-
priority: TaskPriority? = nil,
809-
operation: sending @escaping () async -> Success
810-
) -> Task<Success, Failure> {
811-
// Set up the job flags for a new task.
812-
let flags = taskCreateFlags(
813-
priority: priority, isChildTask: false, copyTaskLocals: false,
814-
inheritContext: false, enqueueJob: true,
815-
addPendingGroupTaskUnconditionally: false,
816-
isDiscardingTask: false)
817-
818-
// Create the asynchronous task future.
819-
let (task, _) = Builtin.createAsyncTask(flags, operation)
820-
821-
return Task(task)
822-
}
823766
#else
824767
/// Runs the given nonthrowing operation asynchronously
825768
/// as part of a new top-level task.
@@ -880,25 +823,6 @@ extension Task where Failure == Error {
880823
) -> Task<Success, Failure> {
881824
fatalError("Unavailable in task-to-thread concurrency model")
882825
}
883-
#elseif $Embedded
884-
@discardableResult
885-
@_alwaysEmitIntoClient
886-
public static func detached(
887-
priority: TaskPriority? = nil,
888-
operation: sending @escaping () async throws -> Success
889-
) -> Task<Success, Failure> {
890-
// Set up the job flags for a new task.
891-
let flags = taskCreateFlags(
892-
priority: priority, isChildTask: false, copyTaskLocals: false,
893-
inheritContext: false, enqueueJob: true,
894-
addPendingGroupTaskUnconditionally: false,
895-
isDiscardingTask: false)
896-
897-
// Create the asynchronous task future.
898-
let (task, _) = Builtin.createAsyncTask(flags, operation)
899-
900-
return Task(task)
901-
}
902826
#else
903827
/// Runs the given throwing operation asynchronously
904828
/// as part of a new top-level task.

stdlib/public/Concurrency/TaskGroup.swift

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public struct TaskGroup<ChildTaskResult: Sendable> {
327327
self._group = group
328328
}
329329

330-
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY && !$Embedded
330+
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
331331
/// Adds a child task to the group.
332332
///
333333
/// - Parameters:
@@ -409,63 +409,6 @@ public struct TaskGroup<ChildTaskResult: Sendable> {
409409
return true
410410
}
411411

412-
#elseif $Embedded
413-
414-
@_alwaysEmitIntoClient
415-
public mutating func addTask(
416-
priority: TaskPriority? = nil,
417-
operation: sending @escaping () async -> ChildTaskResult
418-
) {
419-
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
420-
let flags = taskCreateFlags(
421-
priority: priority, isChildTask: true, copyTaskLocals: false,
422-
inheritContext: false, enqueueJob: false,
423-
addPendingGroupTaskUnconditionally: true,
424-
isDiscardingTask: false
425-
)
426-
#else
427-
let flags = taskCreateFlags(
428-
priority: priority, isChildTask: true, copyTaskLocals: false,
429-
inheritContext: false, enqueueJob: true,
430-
addPendingGroupTaskUnconditionally: true,
431-
isDiscardingTask: false)
432-
#endif
433-
434-
// Create the task in this group.
435-
_ = Builtin.createAsyncTaskInGroup(flags, _group, operation)
436-
}
437-
438-
@_alwaysEmitIntoClient
439-
public mutating func addTaskUnlessCancelled(
440-
priority: TaskPriority? = nil,
441-
operation: sending @escaping () async -> ChildTaskResult
442-
) -> Bool {
443-
let canAdd = _taskGroupAddPendingTask(group: _group, unconditionally: false)
444-
445-
guard canAdd else {
446-
// the group is cancelled and is not accepting any new work
447-
return false
448-
}
449-
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
450-
let flags = taskCreateFlags(
451-
priority: priority, isChildTask: true, copyTaskLocals: false,
452-
inheritContext: false, enqueueJob: false,
453-
addPendingGroupTaskUnconditionally: false,
454-
isDiscardingTask: false)
455-
#else
456-
let flags = taskCreateFlags(
457-
priority: priority, isChildTask: true, copyTaskLocals: false,
458-
inheritContext: false, enqueueJob: true,
459-
addPendingGroupTaskUnconditionally: false,
460-
isDiscardingTask: false)
461-
#endif
462-
463-
// Create the task in this group.
464-
_ = Builtin.createAsyncTaskInGroup(flags, _group, operation)
465-
466-
return true
467-
}
468-
469412
#else // if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
470413
@available(SwiftStdlib 5.7, *)
471414
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model", renamed: "addTask(operation:)")

0 commit comments

Comments
 (0)