Ir al contenido

Sync Over Async (ARCH9023)

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

Key swift.async.sync-over-async · Severity warning · Category async

Flags DispatchSemaphore.wait / DispatchGroup.wait / DispatchQueue.sync used to block on asynchronous work - deadlocks on the main thread and starves the cooperative pool.

let semaphore = DispatchSemaphore(value: 0)
Task { result = try await load(); semaphore.signal() }
semaphore.wait()
let result = try await load()

Propagate async up to the caller instead of blocking on it.