Skip to content

Implement Send for Cell and RefCell #20309

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
use clone::Clone;
use cmp::PartialEq;
use default::Default;
use kinds::{marker, Copy};
use kinds::{Copy, Send};
use ops::{Deref, DerefMut, Drop};
use option::Option;
use option::Option::{None, Some};
Expand All @@ -167,7 +167,6 @@ use option::Option::{None, Some};
#[stable]
pub struct Cell<T> {
value: UnsafeCell<T>,
noshare: marker::NoSync,
}

impl<T:Copy> Cell<T> {
Expand All @@ -176,7 +175,6 @@ impl<T:Copy> Cell<T> {
pub fn new(value: T) -> Cell<T> {
Cell {
value: UnsafeCell::new(value),
noshare: marker::NoSync,
}
}

Expand Down Expand Up @@ -208,6 +206,9 @@ impl<T:Copy> Cell<T> {
}
}

#[stable]
unsafe impl<T> Send for Cell<T> where T: Send {}

#[stable]
impl<T:Copy> Clone for Cell<T> {
fn clone(&self) -> Cell<T> {
Expand Down Expand Up @@ -235,7 +236,6 @@ impl<T:PartialEq + Copy> PartialEq for Cell<T> {
pub struct RefCell<T> {
value: UnsafeCell<T>,
borrow: Cell<BorrowFlag>,
noshare: marker::NoSync,
}

// Values [1, MAX-1] represent the number of `Ref` active
Expand All @@ -251,7 +251,6 @@ impl<T> RefCell<T> {
RefCell {
value: UnsafeCell::new(value),
borrow: Cell::new(UNUSED),
noshare: marker::NoSync,
}
}

Expand Down Expand Up @@ -341,6 +340,9 @@ impl<T> RefCell<T> {
}
}

#[stable]
unsafe impl<T> Send for RefCell<T> where T: Send {}

#[stable]
impl<T: Clone> Clone for RefCell<T> {
fn clone(&self) -> RefCell<T> {
Expand Down