Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
linux_swift_versions: "[\"6.4\"]"
linux_os_versions: "[\"resolute\"]"
linux_host_archs: "[\"aarch64\"]"
linux_pre_build_command: "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl && curl -fsSL -o /tmp/toolchain.tar.gz https://download.swift.org/tmp/pull-request/91981/9/ubuntu2604/PR-ubuntu2604.tar.gz && tar -xzf /tmp/toolchain.tar.gz -C / && rm /tmp/toolchain.tar.gz"
linux_pre_build_command: "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl && curl -fsSL -o /tmp/toolchain.tar.gz https://download.swift.org/tmp/pull-request/91981/15/ubuntu2604/PR-ubuntu2604.tar.gz && tar -xzf /tmp/toolchain.tar.gz -C / && rm /tmp/toolchain.tar.gz"
windows_swift_versions: "[\"nightly\"]"
linux_build_command: swift test --traits ExperimentalIO

Expand All @@ -44,6 +44,6 @@ jobs:
persist-credentials: false
- name: Pre-build
# The same toolchain of https://github.com/swiftlang/swift/pull/91981 as the shared Linux job.
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl && curl -fsSL -o /tmp/toolchain.tar.gz https://download.swift.org/tmp/pull-request/91981/9/ubuntu2604/PR-ubuntu2604.tar.gz && tar -xzf /tmp/toolchain.tar.gz -C / && rm /tmp/toolchain.tar.gz
run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl && curl -fsSL -o /tmp/toolchain.tar.gz https://download.swift.org/tmp/pull-request/91981/15/ubuntu2604/PR-ubuntu2604.tar.gz && tar -xzf /tmp/toolchain.tar.gz -C / && rm /tmp/toolchain.tar.gz
- name: Build / Test
run: swift test --traits ExperimentalIOUring
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
// The I/O interfaces require a toolchain that contains the split continuation of
// https://github.com/swiftlang/swift/pull/91981, which wires through cancellation and priority
// escalation of the operations. The toolchains can be downloaded from:
// - Linux: https://download.swift.org/tmp/pull-request/91981/9/ubuntu2604/PR-ubuntu2604.tar.gz
// - Linux: https://download.swift.org/tmp/pull-request/91981/15/ubuntu2604/PR-ubuntu2604.tar.gz
// - macOS: https://download.swift.org/tmp/pull-request/91981/2475/xcode/swift-PR-91981-2475-osx.tar.gz
// On macOS, processes have to run against the Concurrency runtime of the toolchain, for example with
// `DYLD_LIBRARY_PATH=<toolchain>/usr/lib/swift/macosx`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,20 @@ extension PThreadTaskExecutor: FileOperationScheduler {
private func performBlocking(_ operation: IOOperation) async throws(IOError) -> Int {
let queue = self.blockingQueue()
return try await withContinuation(of: Int.self, throwing: IOError.self) {
(continuation, awaiter) async throws(IOError) -> Int in
(continuation, waiter) async throws(IOError) -> Int in
let priority = Task.currentPriority
let id = unsafe queue.submit(
operation: operation,
priority: Task.currentPriority,
priority: priority,
continuation: continuation
)
return try await awaiter.wait(
onCancel: { queue.cancel(id) },
onEscalate: { newPriority in queue.escalate(id, to: newPriority) }
return try await waiter.wait(
onCancel: { _ in queue.cancel(id) },
onPriorityEscalated: { _, newPriority in
// The handler also runs once when the wait starts, with the priority that the task has then.
guard newPriority > priority else { return }
queue.escalate(id, to: newPriority)
}
)
}
}
Expand Down
27 changes: 16 additions & 11 deletions Sources/PlatformExecutors/PThread/PThreadExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1021,26 +1021,26 @@ extension PThreadExecutor {
/// Creates a resumer whose resumed tasks run inline if they run on the given task executor.
init(taskExecutor: UnownedTaskExecutor) {
self.resumeConnection = { continuation, result in
unsafe continuation.resume(with: result, on: taskExecutor)
unsafe continuation.resumeSynchronously(with: result, on: taskExecutor)
}
self.resumeByteCount = { continuation, result in
unsafe continuation.resume(with: result, on: taskExecutor)
unsafe continuation.resumeSynchronously(with: result, on: taskExecutor)
}
self.resumeVoid = { continuation, result in
unsafe continuation.resume(with: result, on: taskExecutor)
unsafe continuation.resumeSynchronously(with: result, on: taskExecutor)
}
}

/// Creates a resumer whose resumed tasks run inline if they are isolated to the given serial executor.
init(serialExecutor: UnownedSerialExecutor) {
self.resumeConnection = { continuation, result in
unsafe continuation.resume(with: result, isolatedTo: serialExecutor)
unsafe continuation.resumeSynchronously(with: result, isolatedTo: serialExecutor)
}
self.resumeByteCount = { continuation, result in
unsafe continuation.resume(with: result, isolatedTo: serialExecutor)
unsafe continuation.resumeSynchronously(with: result, isolatedTo: serialExecutor)
}
self.resumeVoid = { continuation, result in
unsafe continuation.resume(with: result, isolatedTo: serialExecutor)
unsafe continuation.resumeSynchronously(with: result, isolatedTo: serialExecutor)
}
}
}
Expand Down Expand Up @@ -1077,15 +1077,20 @@ extension PThreadExecutor {
try await withContinuation(
of: Success.self,
throwing: IOError.self
) { (continuation, awaiter) async throws(IOError) -> Success in
) { (continuation, waiter) async throws(IOError) -> Success in
let priority = Task.currentPriority
guard let id = unsafe self.submit(operation, resuming: resumption(continuation)) else {
// The operation completed synchronously, so there is nothing
// to cancel and no reason to install the handlers.
return try await awaiter.wait()
return try await waiter.wait()
}
return try await awaiter.wait(
onCancel: { self.cancel(id) },
onEscalate: { newPriority in self.escalatePriority(of: id, to: newPriority) }
return try await waiter.wait(
onCancel: { _ in self.cancel(id) },
onPriorityEscalated: { _, newPriority in
// The handler also runs once when the wait starts, with the priority that the task has then.
guard newPriority > priority else { return }
self.escalatePriority(of: id, to: newPriority)
}
)
}
}
Expand Down
Loading