Using semaphores in actor code

We're all curious! The main use case of semaphores, in the current state of the language and its documentation, is to address the "reentrancy problem", aka making sure that a sequence of suspension points cannot overlap. Maybe some people would prefer "do not" over "cannot", but "cannot" is stronger and quite reassuring, so it remains my favorite way to say it.

I can't stress enough the problem of documentation. We often hear about wrong patterns (duly noted), but I don't know where to link to when someone (or myself) has a concurrency puzzle to solve and is looking for the correct pattern. A few years after the introduction of Swift concurrency, the fact that developers are still struggling with it can't be the sole responsibility of said developers.

18 Likes