as the title. is it possible?
The question is rather terse... so it's hard to know what exactly you mean.
Recovering static isolation information from dynamic in a synchronous function is done by assumeIsolated: swift-evolution/proposals/0392-custom-actor-executors.md at main · apple/swift-evolution · GitHub
Otherwise, just write a function on the actor and call it.
There's soon going to be ways to "start Task on an actor" `@isolated(any)` function types if that's your question.
Yes, I don't see this feature at the current version.
if all the actor provides like static func run<T>(resultType: T.Type, body: () throws -> T) async rethrows -> T, from MainActor
I am expecting like:
func foo(actor: (any Actor)?) async {
await type(of: actor)?.run {
// run the code
}
}
Make the actor parameter in foo isolated and you’re done. “Run” functions are an anti pattern imho
Depends what's you actually mean by "dynamically", as already being said. You can pass isolated Actor with latest release:
func foo(_: isolated Actor) async {
await doSmth()
}
In latest main branch there are available support for optionals, and #isolation to have inheritance.