Skip to content

[Concurrency][SE-review update] Task names update #80984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Runtimes/Core/Concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_subdirectory(InternalShims)

gyb_expand(Task+init.swift.gyb Task+init.swift)
gyb_expand(TaskGroup+addTask.swift.gyb TaskGroup+addTask.swift)
gyb_expand(Task+startSynchronously.swift.gyb Task+startSynchronously.swift)

Expand Down Expand Up @@ -90,10 +91,10 @@ add_library(swift_Concurrency
Task+TaskExecutor.swift
TaskCancellation.swift
TaskGroup.swift
TaskGroup+Embedded.swift
TaskLocal.swift
TaskSleep.swift
TaskSleepDuration.swift
"${CMAKE_CURRENT_BINARY_DIR}/Task+init.swift"
"${CMAKE_CURRENT_BINARY_DIR}/TaskGroup+addTask.swift"
"${CMAKE_CURRENT_BINARY_DIR}/Task+startSynchronously.swift")

Expand Down
64 changes: 35 additions & 29 deletions cmake/modules/SwiftSetIfArchBitness.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,45 @@ function(set_if_arch_bitness var_name)
"" # multi-value args
${ARGN})

if("${SIA_ARCH}" STREQUAL "avr")
# FIXME: This is a workaround for Concurrency/CMakeLists.txt setting the GYB_SOURCES in embedded-concurrency
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etcwilde @kubamracek I'm not sure what I'm doing wrong in Runtimes/Core/Concurrency/CMakeLists.txt that the SIA_ARCH ends up like this when we try to add GYB_SOURCES in the

    add_swift_target_library_single(
      embedded-concurrency-${mod}

It seems very much the same like all other modules, like Synchronization, which do this for their gyb as well... Would you be able to help me out so we don't need to do this workaround?

I'm not sure if this workaround is "fine" or would break something in the embedded build for example.

# Need to figure out why the SIA_ARCH we get from there isn't right, and undo this workaround.
# Extract first part of the SIA_ARCH (e.g., "x86_64" from "x86_64-apple-macos")
string(REPLACE "-" ";" SIA_ARCH_LIST "${SIA_ARCH}")
list(GET SIA_ARCH_LIST 0 SIA_ARCH_HEAD)

if("${SIA_ARCH_HEAD}" STREQUAL "avr")
set("${var_name}" "${SIA_CASE_16_BIT}" PARENT_SCOPE)
elseif("${SIA_ARCH}" STREQUAL "i386" OR
"${SIA_ARCH}" STREQUAL "i686" OR
"${SIA_ARCH}" STREQUAL "x86" OR
"${SIA_ARCH}" STREQUAL "armv4t" OR
"${SIA_ARCH}" STREQUAL "armv5" OR
"${SIA_ARCH}" STREQUAL "armv6" OR
"${SIA_ARCH}" STREQUAL "armv6m" OR
"${SIA_ARCH}" STREQUAL "armv7" OR
"${SIA_ARCH}" STREQUAL "armv7k" OR
"${SIA_ARCH}" STREQUAL "arm64_32" OR
"${SIA_ARCH}" STREQUAL "armv7m" OR
"${SIA_ARCH}" STREQUAL "armv7em" OR
"${SIA_ARCH}" STREQUAL "armv7s" OR
"${SIA_ARCH}" STREQUAL "m68k" OR
"${SIA_ARCH}" STREQUAL "riscv32" OR
"${SIA_ARCH}" STREQUAL "wasm32" OR
"${SIA_ARCH}" STREQUAL "powerpc")
elseif("${SIA_ARCH_HEAD}" STREQUAL "i386" OR
"${SIA_ARCH_HEAD}" STREQUAL "i686" OR
"${SIA_ARCH_HEAD}" STREQUAL "x86" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv4t" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv5" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv6" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv6m" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv7" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv7k" OR
"${SIA_ARCH_HEAD}" STREQUAL "arm64_32" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv7m" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv7em" OR
"${SIA_ARCH_HEAD}" STREQUAL "armv7s" OR
"${SIA_ARCH_HEAD}" STREQUAL "m68k" OR
"${SIA_ARCH_HEAD}" STREQUAL "riscv32" OR
"${SIA_ARCH_HEAD}" STREQUAL "wasm32" OR
"${SIA_ARCH_HEAD}" STREQUAL "powerpc")
set("${var_name}" "${SIA_CASE_32_BIT}" PARENT_SCOPE)
elseif("${SIA_ARCH}" STREQUAL "x86_64" OR
"${SIA_ARCH}" STREQUAL "amd64" OR
"${SIA_ARCH}" STREQUAL "arm64" OR
"${SIA_ARCH}" STREQUAL "arm64e" OR
"${SIA_ARCH}" STREQUAL "aarch64" OR
"${SIA_ARCH}" STREQUAL "powerpc64" OR
"${SIA_ARCH}" STREQUAL "powerpc64le" OR
"${SIA_ARCH}" STREQUAL "s390x" OR
"${SIA_ARCH}" STREQUAL "riscv64" OR
"${SIA_ARCH}" STREQUAL "wasm64")
elseif("${SIA_ARCH_HEAD}" STREQUAL "x86_64" OR
"${SIA_ARCH_HEAD}" STREQUAL "amd64" OR
"${SIA_ARCH_HEAD}" STREQUAL "arm64" OR
"${SIA_ARCH_HEAD}" STREQUAL "arm64e" OR
"${SIA_ARCH_HEAD}" STREQUAL "aarch64" OR
"${SIA_ARCH_HEAD}" STREQUAL "powerpc64" OR
"${SIA_ARCH_HEAD}" STREQUAL "powerpc64le" OR
"${SIA_ARCH_HEAD}" STREQUAL "s390x" OR
"${SIA_ARCH_HEAD}" STREQUAL "riscv64" OR
"${SIA_ARCH_HEAD}" STREQUAL "wasm64")
set("${var_name}" "${SIA_CASE_64_BIT}" PARENT_SCOPE)
else()
message(FATAL_ERROR "Unknown architecture: ${SIA_ARCH}")
message(FATAL_ERROR "Unknown architecture: ${SIA_ARCH_HEAD} (prefix of ${SIA})")
endif()
endfunction()

13 changes: 10 additions & 3 deletions stdlib/public/Concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ set(SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES
Task+TaskExecutor.swift
TaskCancellation.swift
TaskGroup.swift
TaskGroup+Embedded.swift
DiscardingTaskGroup.swift
TaskLocal.swift
TaskSleep.swift
Expand Down Expand Up @@ -204,6 +203,12 @@ set(LLVM_OPTIONAL_SOURCES
DispatchGlobalExecutor.cpp
)

set(SWIFT_CONCURRENCY_GYB_SOURCES
Task+init.swift.gyb
TaskGroup+addTask.swift.gyb
Task+startSynchronously.swift.gyb
)

add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
${SWIFT_RUNTIME_CONCURRENCY_C_SOURCES}
${SWIFT_RUNTIME_CONCURRENCY_EXECUTOR_SOURCES}
Expand All @@ -212,8 +217,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
${SWIFT_RUNTIME_CONCURRENCY_NONEMBEDDED_SWIFT_SOURCES}

GYB_SOURCES
TaskGroup+addTask.swift.gyb
Task+startSynchronously.swift.gyb
${SWIFT_CONCURRENCY_GYB_SOURCES}

SWIFT_MODULE_DEPENDS_ANDROID Android
SWIFT_MODULE_DEPENDS_LINUX Glibc
Expand Down Expand Up @@ -309,6 +313,9 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB AND SWIFT_SHOULD_BUILD_EMBEDDED_CONCURRENC
${SWIFT_RUNTIME_CONCURRENCY_SWIFT_SOURCES}
${SWIFT_RUNTIME_CONCURRENCY_EMBEDDED_SWIFT_SOURCES}

GYB_SOURCES
${SWIFT_CONCURRENCY_GYB_SOURCES}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to do this and I've followed the pattern that e.g. the Synchronization module does but I'm not sure why I had the wrong SIA_ARCH in the other file when we try to do it here... Maybe it'd be better to just fix or workaround here rather than in the SetIfArchBitness? I wasn't quite sure how though


SWIFT_COMPILE_FLAGS
${extra_swift_compile_flags} -enable-experimental-feature Embedded
-parse-stdlib -DSWIFT_CONCURRENCY_EMBEDDED
Expand Down
169 changes: 0 additions & 169 deletions stdlib/public/Concurrency/SourceCompatibilityShims.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,175 +87,6 @@ extension Task where Success == Never, Failure == Never {
}
}

@available(SwiftStdlib 5.1, *)
extension Task where Failure == Error {
#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@discardableResult
@_alwaysEmitIntoClient
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
public static func runDetached(
priority: TaskPriority? = nil,
operation: __owned @Sendable @escaping () async throws -> Success
) -> Task<Success, Failure> {
fatalError("Unavailable in task-to-thread concurrency model")
}
#else
@discardableResult
@_alwaysEmitIntoClient
@available(*, deprecated, message: "`Task.runDetached` was replaced by `Task.detached` and will be removed shortly.")
public static func runDetached(
priority: TaskPriority? = nil,
operation: __owned @Sendable @escaping () async throws -> Success
) -> Task<Success, Failure> {
detached(priority: priority, operation: operation)
}
#endif
}

#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
@_alwaysEmitIntoClient
public func detach<T>(
priority: TaskPriority? = nil,
operation: __owned @Sendable @escaping () async -> T
) -> Task<T, Never> {
fatalError("Unavailable in task-to-thread concurrency model")
}
#else
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, deprecated, message: "`detach` was replaced by `Task.detached` and will be removed shortly.")
@_alwaysEmitIntoClient
public func detach<T>(
priority: TaskPriority? = nil,
operation: __owned @Sendable @escaping () async -> T
) -> Task<T, Never> {
Task.detached(priority: priority, operation: operation)
}
#endif

#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
@_alwaysEmitIntoClient
public func detach<T>(
priority: TaskPriority? = nil,
operation: __owned @Sendable @escaping () async throws -> T
) -> Task<T, Error> {
fatalError("Unavailable in task-to-thread concurrency model")
}
#else
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, deprecated, message: "`detach` was replaced by `Task.detached` and will be removed shortly.")
@_alwaysEmitIntoClient
public func detach<T>(
priority: TaskPriority? = nil,
operation: __owned @Sendable @escaping () async throws -> T
) -> Task<T, Error> {
Task.detached(priority: priority, operation: operation)
}
#endif

#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
@_alwaysEmitIntoClient
public func asyncDetached<T>(
priority: TaskPriority? = nil,
@_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
) -> Task<T, Never> {
fatalError("Unavailable in task-to-thread concurrency model")
}
#else
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, deprecated, message: "`asyncDetached` was replaced by `Task.detached` and will be removed shortly.")
@_alwaysEmitIntoClient
public func asyncDetached<T>(
priority: TaskPriority? = nil,
@_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
) -> Task<T, Never> {
return Task.detached(priority: priority, operation: operation)
}
#endif

#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
@_alwaysEmitIntoClient
public func asyncDetached<T>(
priority: TaskPriority? = nil,
@_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
) -> Task<T, Error> {
fatalError("Unavailable in task-to-thread concurrency model")
}
#else
@discardableResult
@available(SwiftStdlib 5.1, *)
@available(*, deprecated, message: "`asyncDetached` was replaced by `Task.detached` and will be removed shortly.")
@_alwaysEmitIntoClient
public func asyncDetached<T>(
priority: TaskPriority? = nil,
@_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
) -> Task<T, Error> {
return Task.detached(priority: priority, operation: operation)
}
#endif

#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.1, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
@discardableResult
@_alwaysEmitIntoClient
public func async<T>(
priority: TaskPriority? = nil,
@_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
) -> Task<T, Never> {
fatalError("Unavailable in task-to-thread concurrency model")
}
#else
@available(SwiftStdlib 5.1, *)
@available(*, deprecated, message: "`async` was replaced by `Task.init` and will be removed shortly.")
@discardableResult
@_alwaysEmitIntoClient
public func async<T>(
priority: TaskPriority? = nil,
@_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async -> T
) -> Task<T, Never> {
.init(priority: priority, operation: operation)
}
#endif

#if SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
@available(SwiftStdlib 5.1, *)
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
@discardableResult
@_alwaysEmitIntoClient
public func async<T>(
priority: TaskPriority? = nil,
@_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
) -> Task<T, Error> {
fatalError("Unavailable in task-to-thread concurrency model")
}
#else
@available(SwiftStdlib 5.1, *)
@available(*, deprecated, message: "`async` was replaced by `Task.init` and will be removed shortly.")
@discardableResult
@_alwaysEmitIntoClient
public func async<T>(
priority: TaskPriority? = nil,
@_inheritActorContext @_implicitSelfCapture operation: __owned @Sendable @escaping () async throws -> T
) -> Task<T, Error> {
.init(priority: priority, operation: operation)
}
#endif

@available(SwiftStdlib 5.1, *)
extension Task where Success == Never, Failure == Never {
@available(*, deprecated, message: "`Task.Group` was replaced by `ThrowingTaskGroup` and `TaskGroup` and will be removed shortly.")
Expand Down
Loading