Swift question: there is a library that has some functionality, but it's implemented as an actor. I'm working a a completely synchronous program (a CLI app that builds a static website), but I want to use a function from this actor from normal non-concurrent code.

In the example code for using the library it awaits a function call. Is it possible to call this using some kind of concurrent-in-non-concurrent wrapper?

The library in question is MarkdownSyntax, and I suppose it's implemented as an actor for performance reasons in a UI context (do stuff in the background I presume?).

#swiftlang #askfedi

@torb from out of my head, wrap the call into Task { … } and then use a (think) semaphore (setup before the task) to wait for the tasks completion.

@V_ Oh interesting. I'd love to not have to make my app async only for this specific part.

Oh, this is the “bad” way @Cyberbeni warned me about. Oh well, this is just for my personal static site generator, I already program it somewhat unconventional ways.

But thanks!

@torb I’ve seen that @mortenbekditlevsen has posted a complete example, that was what I tried to explain (from head) yesterday. Do you have more details about the warning you got? I use this style of code myself as well - not that I have a bug in it and don’t know it.

Btw I’m not sure if working about having something async in an otherwise non async codebase would be a big deal. At least I find it a lot less intrusive when you can use await’s instead of callbacks.