Skip to content

Commit

Permalink
[gardening]
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Sep 8, 2024
1 parent 7bdb47e commit b809383
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Tests/IdentifiableContinuationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private extension Actor {

func identifiableContinuation<T: Sendable>(
body: @Sendable (IdentifiableContinuation<T, Never>) -> Void,
onCancel handler: @Sendable (IdentifiableContinuation<T, Never>.ID) -> Void = { _ in }
onCancel handler: @Sendable (IdentifiableContinuation<T, Never>.ID) -> Void = { _ in }
) async -> T {
#if compiler(>=6.0)
await withIdentifiableContinuation(body: body, onCancel: handler)
Expand All @@ -277,7 +277,7 @@ private extension Actor {

func throwingIdentifiableContinuation<T: Sendable>(
body: @Sendable (IdentifiableContinuation<T, any Error>) -> Void,
onCancel handler: @Sendable (IdentifiableContinuation<T, any Error>.ID) -> Void = { _ in }
onCancel handler: @Sendable (IdentifiableContinuation<T, any Error>.ID) -> Void = { _ in }
) async throws -> T {
#if compiler(>=6.0)
try await withIdentifiableThrowingContinuation(body: body, onCancel: handler)
Expand Down
16 changes: 8 additions & 8 deletions Tests/IdentifiableContinuationXCTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class IdentifiableContinuationAsyncXCTests: XCTestCase {
let waiter = Waiter<String?, Never>()

let task = await waiter.makeTask(onCancel: nil)
await Task.sleep(seconds: 0.1)
try? await Task.sleep(seconds: 0.1)
var isEmpty = await waiter.isEmpty
XCTAssertFalse(isEmpty)
task.cancel()
Expand All @@ -80,7 +80,7 @@ final class IdentifiableContinuationAsyncXCTests: XCTestCase {
let waiter = Waiter<String?, Never>()

let task = await waiter.makeTask(delay: 1.0, onCancel: nil)
await Task.sleep(seconds: 0.1)
try? await Task.sleep(seconds: 0.1)
let isEmpty = await waiter.isEmpty
XCTAssertTrue(isEmpty)
task.cancel()
Expand Down Expand Up @@ -129,7 +129,7 @@ final class IdentifiableContinuationAsyncXCTests: XCTestCase {
let waiter = Waiter<String?, any Error>()

let task = await waiter.makeTask(onCancel: .failure(CancellationError()))
await Task.sleep(seconds: 0.1)
try? await Task.sleep(seconds: 0.1)
var isEmpty = await waiter.isEmpty
XCTAssertFalse(isEmpty)
task.cancel()
Expand All @@ -145,7 +145,7 @@ final class IdentifiableContinuationAsyncXCTests: XCTestCase {
let waiter = Waiter<String?, any Error>()

let task = await waiter.makeTask(delay: 1.0, onCancel: .failure(CancellationError()))
await Task.sleep(seconds: 0.1)
try? await Task.sleep(seconds: 0.1)
let isEmpty = await waiter.isEmpty
XCTAssertTrue(isEmpty)
task.cancel()
Expand All @@ -166,7 +166,7 @@ private actor Waiter<T: Sendable, E: Error> {

func makeTask(delay: TimeInterval = 0, onCancel: T) -> Task<T, Never> where E == Never {
Task {
await Task.sleep(seconds: delay)
try? await Task.sleep(seconds: delay)
#if compiler(>=6.0)
return await withIdentifiableContinuation {
addContinuation($0)
Expand All @@ -185,7 +185,7 @@ private actor Waiter<T: Sendable, E: Error> {

func makeTask(delay: TimeInterval = 0, onCancel: Result<T, E>) -> Task<T, any Error> where E == any Error {
Task {
await Task.sleep(seconds: delay)
try? await Task.sleep(seconds: delay)
#if compiler(>=6.0)
return try await withIdentifiableThrowingContinuation {
addContinuation($0)
Expand Down Expand Up @@ -240,8 +240,8 @@ private actor Waiter<T: Sendable, E: Error> {
}

private extension Task where Success == Never, Failure == Never {
static func sleep(seconds: TimeInterval) async {
try? await sleep(nanoseconds: UInt64(1_000_000_000 * seconds))
static func sleep(seconds: TimeInterval) async throws {
try await sleep(nanoseconds: UInt64(1_000_000_000 * seconds))
}
}

Expand Down

0 comments on commit b809383

Please sign in to comment.