Skip to content

Add {Sync, Send} on ArcCell #140

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
icorderi opened this issue May 10, 2017 · 3 comments
Closed

Add {Sync, Send} on ArcCell #140

icorderi opened this issue May 10, 2017 · 3 comments

Comments

@icorderi
Copy link

Shouldn't ArcCell have impl {Sync, Send}?

I guess T has to be Send:

unsafe impl<T: Send> Sync for ArcCell<T> {}
unsafe impl<T: Send> Send for ArcCell<T> {}
@ghost
Copy link

ghost commented Jul 6, 2017

This is the definition of the struct:

pub struct ArcCell<T>(AtomicUsize, PhantomData<Arc<T>>);

ArcCell simply inherits the constraints of Arc<T> -- it is Sync + Send if T: Send + Sync.

@ghost ghost closed this as completed Jul 6, 2017
@Vtec234
Copy link
Member

Vtec234 commented Jul 6, 2017

While it is true that the inherited traits are correct, it might be worth it to consider explicitly impling or !impl ing Send and Sync for all types in crossbeam, given the finnicky nature of concurrent programming. An example of when implicitness backfired is rust-lang/rust#41622.

@ghost
Copy link

ghost commented Jul 6, 2017

@Vtec234 I agree. Also, it's good to have explicit impls of Send and Sync in the generated docs.

This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants