Skip to content

Instantly share code, notes, and snippets.

@juanarzola
Last active August 24, 2025 11:51
Show Gist options
  • Save juanarzola/09b2749fcc540a579fcb24d718459e24 to your computer and use it in GitHub Desktop.
Save juanarzola/09b2749fcc540a579fcb24d718459e24 to your computer and use it in GitHub Desktop.
public extension Task where Success == Void , Failure == Never {
// Suspends until the task is cancelled
static func cancellation() async -> Void {
let s = AsyncStream<Void>{ continuation in }
for await _ in s {
}
}
// EMITS INFINITE ELEMENTS CPU 100%
static func cancellation() async -> Void {
let s = AsyncStream<Void>{ }
for await _ in s {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment