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 You can have an async entrypoint. You can also just call RunLoop.main.run() or dispatchMain() and then call exit(0) from other places in your program.

There are some bad ways to wait in synchronous context, like DispatchSemaphore and DispatchGroup.

Example of async entrypoint: https://codeberg.org/Cyberbeni/auth.home.arpa/src/branch/master/Sources/auth_home_arpa/Entrypoint.swift

auth.home.arpa/Sources/auth_home_arpa/Entrypoint.swift at master

auth.home.arpa - Minimal forward_auth service for Caddy and other reverse proxies.

Codeberg.org
@Cyberbeni Thank so much for answering by the way!