Her phone lagged, she tapped roll twice. Two turns?
transcript
Asha's phone lags. So she taps roll again. Two requests reach the game. Does she get two turns?
Fix one: check whose turn it is. Both taps check at once. Both read Asha's turn. Both move her. The check got raced. Fix two: a lock around the move. Now they run one by one. And each one still moves her. Two turns again.
Here's the trick. You need both, in one place. One lock per game, with the turn check inside it.
Tap one takes the game's lock. Tap two waits. Is it Asha's turn? Yes. She rolls and moves. The turn passes to Bilal. Then the lock is released. Tap two gets the lock. Asha's turn? Not any more.
Bilal taps before his turn? Told: it is Asha's turn. Asha's double tap? She moves once. A tap after the game? Game over. Asha has already won.
A check alone gets raced. A lock alone moves her twice. One lock per game, the turn check inside. A double tap moves once.
Full breakdown in the lecture.