Re:Rust vs C Pitfalls
by netheril96 on Wednesday December 28, 2016 @09:15AM
(#13270560)
Why is a thread local variable atomic?
[ Parent
| on HN ]
Re:Rust vs C Pitfalls
by burntsushi on Wednesday December 28, 2016 @09:48AM
(#13270762)
Because an atomic provides interior mutability for `usize`.
(It's a hack that plays on the GP's specific example of a counter. It doesn't generalize arbitrarily to removing use of RefCell for thread locals in safe code.)