These are chat archives for rust-lang/rust
Please tell me if my understanding is correct. I couldn't find any documentation explaining it.
Syncappropriately, and the compiler simply checks for compatibility of the closure object passed to the
move || local_var + 1, a closure object (say
f) is generated by the compiler. If
local_var(and all the objects wrapped) implements
fwill be marked
Sync. How does Rust find out about "sharing"? Is
Arctreated as a reference to the an object, as opposed to a first class object, by the compiler? How does it do that? How does it distinguish objects of type
Arc<T>when T is
Right now, I'm looking at rust compiler as a magical program (it really is)!! Sorry for my laziness to browse the source code to find the answer.
Tis also both
impl<T> Send for Arc<T> where T: Send + Sync + ?Sized
impl<T> Sync for Arc<T> where T: Send + Sync + ?Sized
RefCell<U>does not impl
Sync, and so if you put it in an
Arc<T>then that Arc will not be
usize, for example, is
Syncright?...... Ahh... Immutability: "
&Tis thread safe"... So
Syncif that interior mutability is thread safe, aka it uses
usizedoesn't offer interior mutability it is automatically
Syncwhich confused me
impl<T> Sync for Arc<T>, making no mention of
T's traits... Thanks a lot...
liballocwhile the other is for
stdre-exporting types from other internal crates makes life difficult for
Syncexists specifically due to
Arc. If there was no
Arc, there would be no need for
Sync(since there is no longer