Ir al contenido

Blocking Call In Async (ARCH9028)

Esta página aún no está disponible en tu idioma.

Key swift.async.blocking-call-in-async · Severity error · Category async

Flags sleep(), Thread.sleep and usleep inside async functions - they block a cooperative-pool thread instead of suspending.

func poll() async {
sleep(1)
}
func poll() async throws {
try await Task.sleep(for: .seconds(1))
}

Use Task.sleep.