3 ms·
This is a pretty standard multithreading problem that has nothing to do with mutability or immutability.
by zak_mc_kracken 11y ago
This is a pretty standard multithreading problem that has nothing to do with mutability or immutability.
- agumonkey 11y agoMutability implies caring about order. I think that's why GP used this example.
- loup-vaillant 11y agoIndeed. This problem arises even in a single thread setting. Let's say 2 units aim at each other, and in frame N, they are at range of each other. Here's what should happen: - Unit1 kills unit2 - Unit2 kills unit1 If you double buffer your actions properly, both unit will be dead at frame N+1. If however you modify your data in place, this may happen: 1. Unit1 kills unit2 => delete unit 2 2. Unit2 no longer exists. Unit1 lives. Or, this may happen: 1. Unit2 kills unit1 => delete unit1 2. Unit1 no longer exists. Oops. Oops. What definitely does not happen is the double kill. StarcraftII can live with that, but other games, like Frozen Synapse, would be broken.
- agumonkey 11y agoWhat you call double buffer, other call transaction I believe, and it's a system design. You have clear steps where information is gathered and rules are applied. In that case you take all the attacks, computes the damages, apply them and prune the dead.