Async: wait blocking for await

I have a 3rd party library which has a "normal" sync handler block. I would run some async functions in this handler, but I need to wait for the task:

// 3rd party
func something(block: () -> Int) {

// my call
func interesting() async -> Int {

something {
    let t = Task {
        await interesting()
     return /* await*/ t.value // how can I wait for this task to return it?

How can I archive this?
In Kotlin, you have runBlocking.

1 Like

AFAIK there is no way to do this in Swift Concurrency.
When I had to do this (which is not a great idea) I used GCD semaphores to block the current queue and wait.

Terms of Service

Privacy Policy

Cookie Policy