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
7 changes: 7 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ let package = Package(
)
]
)

for target in package.targets {
target.swiftSettings = (target.swiftSettings ?? []) + [
.swiftLanguageMode(.v6),
.enableUpcomingFeature("ExistentialAny")
]
}
8 changes: 5 additions & 3 deletions Sources/PrincipleConcurrency/TaskTimeLimit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ private enum TaskTimeLimit {

enum Event<Success: Sendable> {

case taskFinished(Result<Success, Error>)
case taskFinished(Result<Success, any Error>)
case parentTaskCancelled
case timeLimitExceeded
}
}

internal func withTimeLimit<C: Clock, Success: Sendable>( // swiftlint:disable:this function_parameter_count
throwing timeLimitExceededError: @autoclosure () -> Error,
throwing timeLimitExceededError: @autoclosure () -> any Error,
after deadline: C.Instant,
tolerance: C.Instant.Duration?,
clock: C,
Expand All @@ -32,13 +32,15 @@ internal func withTimeLimit<C: Clock, Success: Sendable>( // swiftlint:disable:t

let result = await withTaskGroup(
of: TaskTimeLimit.Event<Success>.self,
returning: Result<Success, Error>.self,
returning: Result<Success, any Error>.self,
isolation: isolation,
body: { group in
var transfer = transfer.take()

group.addTask(priority: priority) {
do {
// Review after closure isolation control gets implemented
// https://forums.swift.org/t/closure-isolation-control/70378
let success = try await transfer.finalize()()
return .taskFinished(.success(success))
} catch {
Expand Down
Loading