Actor is reentrant. This means that func endpoint() async -> Result
can be called several times. Yes, it is guaranteed that at the same time only one task can be executed on an actor. But after function is suspended, another call can occur.
Image the following:
func endpoint() async -> Result
is called. Under the hood it calls thewithCheckedThrowingContinuation
function, where old callback based function is called. Immediately after thatwithCheckedThrowingContinuation
become suspended until continuation will be resumed. So, as it becomes suspended, actor "become free" and can execute another func.func endpoint() async -> Result
is called one more time, and then one more....- lots of call to
func endpoint() async -> Result
were made - the first call of
func endpoint() async -> Result
resumed
There are some separate discussions like Actor Reentrancy - #2 by DevAndArtist