SE-0304 (3rd review): Structured Concurrency

That sleep has an unlabeled parameter specified in nanoseconds is definitely a problem. I'm not sure we want to push the idea of specifying seconds as a Double down into the standard library at all, and doing so for this one API seems unfortunate. Perhaps the easy way out is to use an argument label:

extension Task where Success == Never, Failure == Never {
  public static func sleep(nanoseconds: UInt64) async
}

The API is intentionally ugly, and leaves open space for us to create a nicer sleep(_:) with a proper time type at some point in the future.

Yeah. The AsyncStream proposal and modify accessors consistently use "yield" to mean "produce a value". I agree that suspend is a better term here.

Only the current task. You cannot ask someone else's task to suspend, because they might not be at a potential suspension point.

Doug

5 Likes