|
|
|
|
|
by kazinator
857 days ago
|
|
And then hit annoying roadblocks when you do want to pass those objects between threads? You should write code to minimize the reference count bumps; they are waste of time whether atomic or not. If the code spends 0.5% of its time bumping references, and you magically reduce that to zero using alien optimization technology, that only gives you a 0.5% improvement. If the code spends 10% of its time bumping references up and down, something is wrong. |
|
It's even possible to share an Rc-managed value across threads without switching to Arc, as long as the other thread(s) never needs to change the reference count and can be "scoped" (https://doc.rust-lang.org/stable/std/thread/fn.scope.html) to some lifetime that some particular Rc outlives.