Skip to content

Naming & minor type adjustments to std::unstable::sync::UnsafeAtomicRcBox #8790

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use sync;
use sync::{Mutex, RWLock};

use std::cast;
use std::unstable::sync::UnsafeAtomicRcBox;
use std::unstable::sync::UnsafeArc;
use std::task;
use std::borrow;

Expand Down Expand Up @@ -108,7 +108,7 @@ impl<'self> Condvar<'self> {
****************************************************************************/

/// An atomically reference counted wrapper for shared immutable state.
pub struct Arc<T> { priv x: UnsafeAtomicRcBox<T> }
pub struct Arc<T> { priv x: UnsafeArc<T> }


/**
Expand All @@ -118,7 +118,7 @@ pub struct Arc<T> { priv x: UnsafeAtomicRcBox<T> }
impl<T:Freeze+Send> Arc<T> {
/// Create an atomically reference counted wrapper.
pub fn new(data: T) -> Arc<T> {
Arc { x: UnsafeAtomicRcBox::new(data) }
Arc { x: UnsafeArc::new(data) }
}

pub fn get<'a>(&'a self) -> &'a T {
Expand Down Expand Up @@ -160,7 +160,7 @@ impl<T:Freeze + Send> Clone for Arc<T> {
#[doc(hidden)]
struct MutexArcInner<T> { priv lock: Mutex, priv failed: bool, priv data: T }
/// An Arc with mutable data protected by a blocking mutex.
struct MutexArc<T> { priv x: UnsafeAtomicRcBox<MutexArcInner<T>> }
struct MutexArc<T> { priv x: UnsafeArc<MutexArcInner<T>> }


impl<T:Send> Clone for MutexArc<T> {
Expand All @@ -187,7 +187,7 @@ impl<T:Send> MutexArc<T> {
lock: Mutex::new_with_condvars(num_condvars),
failed: false, data: user_data
};
MutexArc { x: UnsafeAtomicRcBox::new(data) }
MutexArc { x: UnsafeArc::new(data) }
}

/**
Expand Down Expand Up @@ -309,7 +309,7 @@ struct RWArcInner<T> { priv lock: RWLock, priv failed: bool, priv data: T }
*/
#[no_freeze]
struct RWArc<T> {
priv x: UnsafeAtomicRcBox<RWArcInner<T>>,
priv x: UnsafeArc<RWArcInner<T>>,
}

impl<T:Freeze + Send> Clone for RWArc<T> {
Expand All @@ -335,7 +335,7 @@ impl<T:Freeze + Send> RWArc<T> {
lock: RWLock::new_with_condvars(num_condvars),
failed: false, data: user_data
};
RWArc { x: UnsafeAtomicRcBox::new(data), }
RWArc { x: UnsafeArc::new(data), }
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::comm;
use std::comm::SendDeferred;
use std::comm::{GenericPort, Peekable};
use std::task;
use std::unstable::sync::{Exclusive, UnsafeAtomicRcBox};
use std::unstable::sync::{Exclusive, UnsafeArc};
use std::unstable::atomics;
use std::unstable::finally::Finally;
use std::util;
Expand Down Expand Up @@ -448,7 +448,7 @@ struct RWLockInner {
pub struct RWLock {
priv order_lock: Semaphore,
priv access_lock: Sem<~[WaitQueue]>,
priv state: UnsafeAtomicRcBox<RWLockInner>,
priv state: UnsafeArc<RWLockInner>,
}

impl RWLock {
Expand All @@ -460,7 +460,7 @@ impl RWLock {
* Similar to mutex_with_condvars.
*/
pub fn new_with_condvars(num_condvars: uint) -> RWLock {
let state = UnsafeAtomicRcBox::new(RWLockInner {
let state = UnsafeArc::new(RWLockInner {
read_mode: false,
read_count: atomics::AtomicUint::new(0),
});
Expand Down
10 changes: 5 additions & 5 deletions src/libstd/rt/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rt::local::Local;
use rt::select::{SelectInner, SelectPortInner};
use select::{Select, SelectPort};
use unstable::atomics::{AtomicUint, AtomicOption, Acquire, Relaxed, SeqCst};
use unstable::sync::UnsafeAtomicRcBox;
use unstable::sync::UnsafeArc;
use util::Void;
use comm::{GenericChan, GenericSmartChan, GenericPort, Peekable};
use cell::Cell;
Expand Down Expand Up @@ -567,14 +567,14 @@ impl<'self, T> SelectPort<T> for &'self Port<T> { }

pub struct SharedChan<T> {
// Just like Chan, but a shared AtomicOption instead of Cell
priv next: UnsafeAtomicRcBox<AtomicOption<StreamChanOne<T>>>
priv next: UnsafeArc<AtomicOption<StreamChanOne<T>>>
}

impl<T> SharedChan<T> {
pub fn new(chan: Chan<T>) -> SharedChan<T> {
let next = chan.next.take();
let next = AtomicOption::new(~next);
SharedChan { next: UnsafeAtomicRcBox::new(next) }
SharedChan { next: UnsafeArc::new(next) }
}
}

Expand Down Expand Up @@ -620,7 +620,7 @@ impl<T> Clone for SharedChan<T> {

pub struct SharedPort<T> {
// The next port on which we will receive the next port on which we will receive T
priv next_link: UnsafeAtomicRcBox<AtomicOption<PortOne<StreamPortOne<T>>>>
priv next_link: UnsafeArc<AtomicOption<PortOne<StreamPortOne<T>>>>
}

impl<T> SharedPort<T> {
Expand All @@ -630,7 +630,7 @@ impl<T> SharedPort<T> {
let (next_link_port, next_link_chan) = oneshot();
next_link_chan.send(next_data_port);
let next_link = AtomicOption::new(~next_link_port);
SharedPort { next_link: UnsafeAtomicRcBox::new(next_link) }
SharedPort { next_link: UnsafeArc::new(next_link) }
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/libstd/rt/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ use rt::task::Task;
use task::spawn::Taskgroup;
use to_bytes::IterBytes;
use unstable::atomics::{AtomicUint, Relaxed};
use unstable::sync::{UnsafeAtomicRcBox, LittleLock};
use unstable::sync::{UnsafeArc, LittleLock};
use util;

static KILLED_MSG: &'static str = "killed by linked failure";
Expand All @@ -170,7 +170,7 @@ static KILL_KILLED: uint = 1;
static KILL_UNKILLABLE: uint = 2;

struct KillFlag(AtomicUint);
type KillFlagHandle = UnsafeAtomicRcBox<KillFlag>;
type KillFlagHandle = UnsafeArc<KillFlag>;

/// A handle to a blocked task. Usually this means having the ~Task pointer by
/// ownership, but if the task is killable, a killer can steal it at any time.
Expand Down Expand Up @@ -211,7 +211,7 @@ struct KillHandleInner {

/// State shared between tasks used for task killing during linked failure.
#[deriving(Clone)]
pub struct KillHandle(UnsafeAtomicRcBox<KillHandleInner>);
pub struct KillHandle(UnsafeArc<KillHandleInner>);

/// Per-task state related to task death, killing, failure, etc.
pub struct Death {
Expand Down Expand Up @@ -317,7 +317,7 @@ impl BlockedTask {
let handles = match self {
Unkillable(task) => {
let flag = unsafe { KillFlag(AtomicUint::new(cast::transmute(task))) };
UnsafeAtomicRcBox::newN(flag, num_handles)
UnsafeArc::newN(flag, num_handles)
}
Killable(flag_arc) => flag_arc.cloneN(num_handles),
};
Expand Down Expand Up @@ -380,8 +380,8 @@ impl Eq for KillHandle {
impl KillHandle {
pub fn new() -> (KillHandle, KillFlagHandle) {
let (flag, flag_clone) =
UnsafeAtomicRcBox::new2(KillFlag(AtomicUint::new(KILL_RUNNING)));
let handle = KillHandle(UnsafeAtomicRcBox::new(KillHandleInner {
UnsafeArc::new2(KillFlag(AtomicUint::new(KILL_RUNNING)));
let handle = KillHandle(UnsafeArc::new(KillHandleInner {
// Linked failure fields
killed: flag,
unkillable: AtomicUint::new(KILL_RUNNING),
Expand Down Expand Up @@ -460,7 +460,7 @@ impl KillHandle {
pub fn notify_immediate_failure(&mut self) {
// A benign data race may happen here if there are failing sibling
// tasks that were also spawned-watched. The refcount's write barriers
// in UnsafeAtomicRcBox ensure that this write will be seen by the
// in UnsafeArc ensure that this write will be seen by the
// unwrapper/destructor, whichever task may unwrap it.
unsafe { (*self.get()).any_child_failed = true; }
}
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/rt/message_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use kinds::Send;
use vec::OwnedVector;
use cell::Cell;
use option::*;
use unstable::sync::{UnsafeAtomicRcBox, LittleLock};
use unstable::sync::{UnsafeArc, LittleLock};
use clone::Clone;

pub struct MessageQueue<T> {
priv state: UnsafeAtomicRcBox<State<T>>
priv state: UnsafeArc<State<T>>
}

struct State<T> {
Expand All @@ -32,7 +32,7 @@ struct State<T> {
impl<T: Send> MessageQueue<T> {
pub fn new() -> MessageQueue<T> {
MessageQueue {
state: UnsafeAtomicRcBox::new(State {
state: UnsafeArc::new(State {
count: 0,
queue: ~[],
lock: LittleLock::new()
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ use rt::thread::Thread;
use rt::work_queue::WorkQueue;
use rt::uv::uvio::UvEventLoop;
use unstable::atomics::{AtomicInt, SeqCst};
use unstable::sync::UnsafeAtomicRcBox;
use unstable::sync::UnsafeArc;
use vec::{OwnedVector, MutableVector};

/// The global (exchange) heap.
Expand Down Expand Up @@ -311,7 +311,7 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {

// Create a shared cell for transmitting the process exit
// code from the main task to this function.
let exit_code = UnsafeAtomicRcBox::new(AtomicInt::new(0));
let exit_code = UnsafeArc::new(AtomicInt::new(0));
let exit_code_clone = exit_code.clone();

// When the main task exits, after all the tasks in the main
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/rt/sleeper_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ use container::Container;
use vec::OwnedVector;
use option::{Option, Some, None};
use cell::Cell;
use unstable::sync::{UnsafeAtomicRcBox, LittleLock};
use unstable::sync::{UnsafeArc, LittleLock};
use rt::sched::SchedHandle;
use clone::Clone;

pub struct SleeperList {
priv state: UnsafeAtomicRcBox<State>
priv state: UnsafeArc<State>
}

struct State {
Expand All @@ -32,7 +32,7 @@ struct State {
impl SleeperList {
pub fn new() -> SleeperList {
SleeperList {
state: UnsafeAtomicRcBox::new(State {
state: UnsafeArc::new(State {
count: 0,
stack: ~[],
lock: LittleLock::new()
Expand Down
Loading