suppose i have
actor A
{
func x() -> X
func y() -> Y
}
and i want to use it to initialize some (non-Sendable
) structure like:
init(a:A) async
{
self.init(
x: await a.x(),
y: await a.y())
}
formally, this would acquire and release the actor lock twice to allow other code to run in between, so i would be tempted to refactor the two methods into func xy() -> (X, Y)
.
but is this needed? is the compiler able to coalesce the lock acquisitions into a single isolation?