Re:Go’s Type System Is An Embarrassment
by nostrademons on Tuesday January 07, 2014 @02:47PM
(#7019402)
And even more specifically - threads with locks. Shared mutable state is okay as long as any state-swapping operations are atomic, eg. with STM or if you build up the state in one thread, switch it with an atomic pointer swap, and don't let other threads mutate the state.
[ Parent
| on HN ]
Threads with locks are fine as long as the compiler enforces that you take the lock before mutating the data (e.g. Rust). :)
Re:Go’s Type System Is An Embarrassment
by nostrademons on Friday January 10, 2014 @03:44AM
(#7035737)
Annotalysis can do this for C++ as well. The problem is that you need to enforce an ordering on locks to avoid deadlocks. That works fine if they're all within one module. It doesn't work at all if you have to coordinate callbacks across threads from different third-party libraries.
The usual solution I've seen given for this is "Don't invoke callbacks when holding a lock." This is not a viable solution for most programs.