Posts

Post not yet marked as solved
1 Replies
674 Views
Is there a best practice for calling async code and waiting for the result from a synchronous function? The talk called out semaphores as an incorrect solution. Do you recommend using a lock, a dispatch group, or something else? (I suppose this is an anti-pattern in general but since it may rarely be useful, I'd like to know how best to do it.) Thanks! Here's an example of what I'd like to do: func foo() -> Bool { var ok = false async { ok = await bar() // Signal completion } // Wait for completion return ok }
Posted
by kbongort.
Last updated
.