Skip to content

Commit a512765

Browse files
committed
[Concurrency] Update Task.init and TaskGroup+addTask gyb for TaskExecutor
[Concurrency] Adjust tests for renamed initializer [Embedded][Concurrency] Workaround for Gyb+concurrency module+embedded Add Task+init gyb to embedded; Remove TaskGroup+Embedded.swift workaround [Concurrency] Undo build workaround
1 parent cfbe9fa commit a512765

File tree

9 files changed

+139
-501
lines changed

9 files changed

+139
-501
lines changed

Runtimes/Core/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ add_library(swift_Concurrency
9393
Task+TaskExecutor.swift
9494
TaskCancellation.swift
9595
TaskGroup.swift
96-
TaskGroup+Embedded.swift
9796
TaskLocal.swift
9897
TaskSleep.swift
9998
TaskSleepDuration.swift
99+
"${CMAKE_CURRENT_BINARY_DIR}/Task+init.swift"
100100
"${CMAKE_CURRENT_BINARY_DIR}/TaskGroup+addTask.swift"
101101
"${CMAKE_CURRENT_BINARY_DIR}/Task+startSynchronously.swift")
102102

cmake/modules/SwiftSetIfArchBitness.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ function(set_if_arch_bitness var_name)
2727
"${SIA_ARCH}" STREQUAL "powerpc")
2828
set("${var_name}" "${SIA_CASE_32_BIT}" PARENT_SCOPE)
2929
elseif("${SIA_ARCH}" STREQUAL "x86_64" OR
30-
"${SIA_ARCH}" STREQUAL "amd64" OR
31-
"${SIA_ARCH}" STREQUAL "arm64" OR
32-
"${SIA_ARCH}" STREQUAL "arm64e" OR
33-
"${SIA_ARCH}" STREQUAL "aarch64" OR
34-
"${SIA_ARCH}" STREQUAL "powerpc64" OR
35-
"${SIA_ARCH}" STREQUAL "powerpc64le" OR
36-
"${SIA_ARCH}" STREQUAL "s390x" OR
37-
"${SIA_ARCH}" STREQUAL "riscv64" OR
38-
"${SIA_ARCH}" STREQUAL "wasm64")
30+
"${SIA_ARCH}" STREQUAL "amd64" OR
31+
"${SIA_ARCH}" STREQUAL "arm64" OR
32+
"${SIA_ARCH}" STREQUAL "arm64e" OR
33+
"${SIA_ARCH}" STREQUAL "aarch64" OR
34+
"${SIA_ARCH}" STREQUAL "powerpc64" OR
35+
"${SIA_ARCH}" STREQUAL "powerpc64le" OR
36+
"${SIA_ARCH}" STREQUAL "s390x" OR
37+
"${SIA_ARCH}" STREQUAL "riscv64" OR
38+
"${SIA_ARCH}" STREQUAL "wasm64")
3939
set("${var_name}" "${SIA_CASE_64_BIT}" PARENT_SCOPE)
4040
else()
4141
message(FATAL_ERROR "Unknown architecture: ${SIA_ARCH}")

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ set(SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES
129129
Task+TaskExecutor.swift
130130
TaskCancellation.swift
131131
TaskGroup.swift
132-
TaskGroup+Embedded.swift
133132
DiscardingTaskGroup.swift
134133
TaskLocal.swift
135134
TaskSleep.swift
@@ -214,6 +213,12 @@ if((SWIFT_BUILD_CLANG_OVERLAYS
214213
set(SWIFT_CONCURRENCY_DEPENDENCIES _Builtin_float)
215214
endif()
216215

216+
set(SWIFT_CONCURRENCY_GYB_SOURCES
217+
Task+init.swift.gyb
218+
TaskGroup+addTask.swift.gyb
219+
Task+startSynchronously.swift.gyb
220+
)
221+
217222
add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
218223
${SWIFT_RUNTIME_CONCURRENCY_C_SOURCES}
219224
${SWIFT_RUNTIME_CONCURRENCY_EXECUTOR_SOURCES}
@@ -222,9 +227,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
222227
${SWIFT_RUNTIME_CONCURRENCY_NONEMBEDDED_SWIFT_SOURCES}
223228

224229
GYB_SOURCES
225-
Task+init.swift.gyb
226-
TaskGroup+addTask.swift.gyb
227-
Task+startSynchronously.swift.gyb
230+
${SWIFT_CONCURRENCY_GYB_SOURCES}
228231

229232
SWIFT_MODULE_DEPENDS ${SWIFT_CONCURRENCY_DEPENDENCIES}
230233
SWIFT_MODULE_DEPENDS_ANDROID Android
@@ -323,6 +326,9 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
323326
${SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES}
324327
${SWIFT_RUNTIME_CONCURRENCY_EMBEDDED_SWIFT_SOURCES}
325328

329+
GYB_SOURCES
330+
${SWIFT_CONCURRENCY_GYB_SOURCES}
331+
326332
SWIFT_COMPILE_FLAGS
327333
${extra_swift_compile_flags} -enable-experimental-feature Embedded
328334
-parse-stdlib -DSWIFT_CONCURRENCY_EMBEDDED

stdlib/public/Concurrency/SourceCompatibilityShims.swift

Lines changed: 17 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
import Swift
17-
import _Concurrency
1817

1918
@available(SwiftStdlib 5.1, *)
2019
extension Task where Success == Never, Failure == Never {
@@ -88,192 +87,23 @@ extension Task where Success == Never, Failure == Never {
8887
}
8988
}
9089

91-
//@available(SwiftStdlib 5.1, *)
92-
//extension Task where Failure == Error {
93-
// #if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
94-
// @discardableResult
95-
// @_alwaysEmitIntoClient
96-
// @available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
97-
// public static func runDetached(
98-
// priority: TaskPriority? = nil,
99-
// operation: __owned @Sendable @escaping () async throws -> Success
100-
// ) -> Task<Success, Failure> {
101-
// fatalError("Unavailable in task-to-thread concurrency model")
102-
// }
103-
// #else
104-
// @discardableResult
105-
// @_alwaysEmitIntoClient
106-
// @available(*, deprecated, message: "`Task.runDetached` was replaced by `Task.detached` and will be removed shortly.")
107-
// public static func runDetached(
108-
// priority: TaskPriority? = nil,
109-
// operation: __owned @Sendable @escaping () async throws -> Success
110-
// ) -> Task<Success, Failure> {
111-
// detached(priority: priority, operation: operation)
112-
// }
113-
// #endif
114-
//}
115-
//
116-
//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
117-
//@discardableResult
118-
//@available(SwiftStdlib 5.1, *)
119-
//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
120-
//@_alwaysEmitIntoClient
121-
//public func detach<T>(
122-
// priority: TaskPriority? = nil,
123-
// operation: __owned @Sendable @escaping () async -> T
124-
//) -> Task<T, Never> {
125-
// fatalError("Unavailable in task-to-thread concurrency model")
126-
//}
127-
//#else
128-
//@discardableResult
129-
//@available(SwiftStdlib 5.1, *)
130-
//@available(*, deprecated, message: "`detach` was replaced by `Task.detached` and will be removed shortly.")
131-
//@_alwaysEmitIntoClient
132-
//public func detach<T>(
133-
// priority: TaskPriority? = nil,
134-
// operation: __owned @Sendable @escaping () async -> T
135-
//) -> Task<T, Never> {
136-
// Task.detached(priority: priority, operation: operation)
137-
//}
138-
//#endif
139-
//
140-
//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
141-
//@discardableResult
142-
//@available(SwiftStdlib 5.1, *)
143-
//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
144-
//@_alwaysEmitIntoClient
145-
//public func detach<T>(
146-
// priority: TaskPriority? = nil,
147-
// operation: __owned @Sendable @escaping () async throws -> T
148-
//) -> Task<T, Error> {
149-
// fatalError("Unavailable in task-to-thread concurrency model")
150-
//}
151-
//#else
152-
//@discardableResult
153-
//@available(SwiftStdlib 5.1, *)
154-
//@available(*, deprecated, message: "`detach` was replaced by `Task.detached` and will be removed shortly.")
155-
//@_alwaysEmitIntoClient
156-
//public func detach<T>(
157-
// priority: TaskPriority? = nil,
158-
// operation: __owned @Sendable @escaping () async throws -> T
159-
//) -> Task<T, Error> {
160-
// Task.detached(priority: priority, operation: operation)
161-
//}
162-
//#endif
163-
//
164-
//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
165-
//@discardableResult
166-
//@available(SwiftStdlib 5.1, *)
167-
//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
168-
//@_alwaysEmitIntoClient
169-
//public func asyncDetached<T>(
170-
// priority: TaskPriority? = nil,
171-
// @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
172-
//) -> Task<T, Never> {
173-
// fatalError("Unavailable in task-to-thread concurrency model")
174-
//}
175-
//#else
176-
//@discardableResult
177-
//@available(SwiftStdlib 5.1, *)
178-
//@available(*, deprecated, message: "`asyncDetached` was replaced by `Task.detached` and will be removed shortly.")
179-
//@_alwaysEmitIntoClient
180-
//public func asyncDetached<T>(
181-
// priority: TaskPriority? = nil,
182-
// @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
183-
//) -> Task<T, Never> {
184-
// return Task.detached(priority: priority, operation: operation)
185-
//}
186-
//#endif
187-
//
188-
//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
189-
//@discardableResult
190-
//@available(SwiftStdlib 5.1, *)
191-
//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
192-
//@_alwaysEmitIntoClient
193-
//public func asyncDetached<T>(
194-
// priority: TaskPriority? = nil,
195-
// @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
196-
//) -> Task<T, Error> {
197-
// fatalError("Unavailable in task-to-thread concurrency model")
198-
//}
199-
//#else
200-
//@discardableResult
201-
//@available(SwiftStdlib 5.1, *)
202-
//@available(*, deprecated, message: "`asyncDetached` was replaced by `Task.detached` and will be removed shortly.")
203-
//@_alwaysEmitIntoClient
204-
//public func asyncDetached<T>(
205-
// priority: TaskPriority? = nil,
206-
// @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
207-
//) -> Task<T, Error> {
208-
// return Task.detached(priority: priority, operation: operation)
209-
//}
210-
//#endif
211-
//
212-
//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
213-
//@available(SwiftStdlib 5.1, *)
214-
//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
215-
//@discardableResult
216-
//@_alwaysEmitIntoClient
217-
//public func async<T>(
218-
// priority: TaskPriority? = nil,
219-
// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
220-
//) -> Task<T, Never> {
221-
// fatalError("Unavailable in task-to-thread concurrency model")
222-
//}
223-
//#else
224-
//@available(SwiftStdlib 5.1, *)
225-
//@available(*, deprecated, message: "`async` was replaced by `Task.init` and will be removed shortly.")
226-
//@discardableResult
227-
//@_alwaysEmitIntoClient
228-
//public func async<T>(
229-
// priority: TaskPriority? = nil,
230-
// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
231-
//) -> Task<T, Never> {
232-
// .init(priority: priority, operation: operation)
233-
//}
234-
//#endif
235-
//
236-
//#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
237-
//@available(SwiftStdlib 5.1, *)
238-
//@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
239-
//@discardableResult
240-
//@_alwaysEmitIntoClient
241-
//public func async<T>(
242-
// priority: TaskPriority? = nil,
243-
// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
244-
//) -> Task<T, Error> {
245-
// fatalError("Unavailable in task-to-thread concurrency model")
246-
//}
247-
//#else
248-
//@available(SwiftStdlib 5.1, *)
249-
//@available(*, deprecated, message: "`async` was replaced by `Task.init` and will be removed shortly.")
250-
//@discardableResult
251-
//@_alwaysEmitIntoClient
252-
//public func async<T>(
253-
// priority: TaskPriority? = nil,
254-
// @_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
255-
//) -> Task<T, Error> {
256-
// .init(priority: priority, operation: operation)
257-
//}
258-
//#endif
259-
//
260-
//@available(SwiftStdlib 5.1, *)
261-
//extension Task where Success == Never, Failure == Never {
262-
// @available(*, deprecated, message: "`Task.Group` was replaced by `ThrowingTaskGroup` and `TaskGroup` and will be removed shortly.")
263-
// public typealias Group<TaskResult: Sendable> = ThrowingTaskGroup<TaskResult, Error>
264-
//
265-
// @available(*, deprecated, message: "`Task.withGroup` was replaced by `withThrowingTaskGroup` and `withTaskGroup` and will be removed shortly.")
266-
// @_alwaysEmitIntoClient
267-
// public static func withGroup<TaskResult: Sendable, BodyResult>(
268-
// resultType: TaskResult.Type,
269-
// returning returnType: BodyResult.Type = BodyResult.self,
270-
// body: (inout Task.Group<TaskResult>) async throws -> BodyResult
271-
// ) async rethrows -> BodyResult {
272-
// try await withThrowingTaskGroup(of: resultType) { group in
273-
// try await body(&group)
274-
// }
275-
// }
276-
//}
90+
@available(SwiftStdlib 5.1, *)
91+
extension Task where Success == Never, Failure == Never {
92+
@available(*, deprecated, message: "`Task.Group` was replaced by `ThrowingTaskGroup` and `TaskGroup` and will be removed shortly.")
93+
public typealias Group<TaskResult: Sendable> = ThrowingTaskGroup<TaskResult, Error>
94+
95+
@available(*, deprecated, message: "`Task.withGroup` was replaced by `withThrowingTaskGroup` and `withTaskGroup` and will be removed shortly.")
96+
@_alwaysEmitIntoClient
97+
public static func withGroup<TaskResult: Sendable, BodyResult>(
98+
resultType: TaskResult.Type,
99+
returning returnType: BodyResult.Type = BodyResult.self,
100+
body: (inout Task.Group<TaskResult>) async throws -> BodyResult
101+
) async rethrows -> BodyResult {
102+
try await withThrowingTaskGroup(of: resultType) { group in
103+
try await body(&group)
104+
}
105+
}
106+
}
277107

278108
@available(SwiftStdlib 5.1, *)
279109
extension Task {

0 commit comments

Comments
 (0)