Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftactors and actor isolationSingle-choice MCQ

Consider this actor. An external caller `await counter.snapshot()`. Why is it possible for `value` to differ between the two reads inside `snapshot`, and what is the name for this hazard?

actor Counter { var value = 0 func bump() { value += 1 } func snapshot() async -> (Int, Int) { let a = value await Task.yield() let b = value return (a, b) } }