3 ms·
That is where an Actor or CSP style comes in useful, one then avoids the locks by having that state mutated in the context of one coroutine alone. Most problem
by dfawcus 3y ago
That is where an Actor or CSP style comes in useful, one then avoids the locks by having that state mutated in the context of one coroutine alone.
Most problems can be recast in to that form, only a small subset are better handled by mutable shared state (and hence explicit locks. In those cases one should probably be modelling the updates as 'Compare and Swap' / 'Compare and Set' types of mutable operation, hence avoiding the situation where unexpected preemption can occur while holding a lock.
From my perspective, having use both forms (manually and with language support), I generally find the coroutine (plus Actor/CSP) scheme to be easier to work with and reason about.