diff --git a/stdlib/public/Concurrency/TaskSleep.swift b/stdlib/public/Concurrency/TaskSleep.swift index 62ab2bad374a2..baad779a4df0e 100644 --- a/stdlib/public/Concurrency/TaskSleep.swift +++ b/stdlib/public/Concurrency/TaskSleep.swift @@ -14,10 +14,7 @@ import Swift @available(SwiftStdlib 5.5, *) extension Task where Success == Never, Failure == Never { - /// Suspends the current task for _at least_ the given duration - /// in nanoseconds. - /// - /// This function does _not_ block the underlying thread. + @available(*, deprecated, renamed: "Task.sleep(nanoseconds:)") public static func sleep(_ duration: UInt64) async { let currentTask = Builtin.getCurrentAsyncTask() let priority = getJobFlags(currentTask).priority ?? Task.currentPriority._downgradeUserInteractive diff --git a/test/Concurrency/async_task_groups.swift b/test/Concurrency/async_task_groups.swift index 49760bb104b79..9da0ded734e1f 100644 --- a/test/Concurrency/async_task_groups.swift +++ b/test/Concurrency/async_task_groups.swift @@ -13,7 +13,7 @@ func asyncThrowsOnCancel() async throws -> Int { // terrible suspend-spin-loop -- do not do this // only for purposes of demonstration while Task.isCancelled { - await Task.sleep(1_000_000_000) + try? await Task.sleep(nanoseconds: 1_000_000_000) } throw CancellationError()