Skip to content

Commit

Permalink
auto merge of #6387 : brson/rust/unstable, r=brson
Browse files Browse the repository at this point in the history
r? @pcwalton

* Move `SharedMutableState`, `LittleLock`, and `Exclusive` from `core::unstable` to `core::unstable::sync`
* Modernize the `SharedMutableState` interface with methods
* Rename `SharedMutableState` to `UnsafeAtomicRcBox` to match `RcBox`.
  • Loading branch information
bors committed May 13, 2013
2 parents 3abc5b3 + 369231b commit ad5bfd6
Show file tree
Hide file tree
Showing 13 changed files with 434 additions and 424 deletions.
4 changes: 2 additions & 2 deletions src/libcore/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use option::{Option, Some, None};
use uint;
use unstable;
use vec;
use unstable::Exclusive;
use util::replace;
use unstable::sync::{Exclusive, exclusive};

use pipes::{recv, try_recv, wait_many, peek, PacketHeader};

Expand Down Expand Up @@ -304,7 +304,7 @@ pub struct SharedChan<T> {
impl<T: Owned> SharedChan<T> {
/// Converts a `chan` into a `shared_chan`.
pub fn new(c: Chan<T>) -> SharedChan<T> {
SharedChan { ch: unstable::exclusive(c) }
SharedChan { ch: exclusive(c) }
}
}
Expand Down
1 change: 1 addition & 0 deletions src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ pub mod util;
/* Unsupported interfaces */

// Private APIs
#[path = "unstable/mod.rs"]
pub mod unstable;

/* For internal use, not exported */
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ FIXME #4726: It would probably be appropriate to make this a real global
*/
fn with_env_lock<T>(f: &fn() -> T) -> T {
use unstable::global::global_data_clone_create;
use unstable::{Exclusive, exclusive};
use unstable::sync::{Exclusive, exclusive};

struct SharedValue(());
type ValueMutex = Exclusive<SharedValue>;
Expand Down Expand Up @@ -855,7 +855,7 @@ pub fn change_dir(p: &Path) -> bool {
/// is otherwise unsuccessful.
pub fn change_dir_locked(p: &Path, action: &fn()) -> bool {
use unstable::global::global_data_clone_create;
use unstable::{Exclusive, exclusive};
use unstable::sync::{Exclusive, exclusive};
fn key(_: Exclusive<()>) { }
Expand Down
13 changes: 7 additions & 6 deletions src/libcore/task/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ use task::{ExistingScheduler, SchedulerHandle};
use task::unkillable;
use uint;
use util;
use unstable::sync::{Exclusive, exclusive};

#[cfg(test)] use task::default_task_opts;

Expand Down Expand Up @@ -128,7 +129,7 @@ struct TaskGroupData {
// tasks in this group.
descendants: TaskSet,
}
type TaskGroupArc = unstable::Exclusive<Option<TaskGroupData>>;
type TaskGroupArc = Exclusive<Option<TaskGroupData>>;

type TaskGroupInner<'self> = &'self mut Option<TaskGroupData>;

Expand Down Expand Up @@ -158,7 +159,7 @@ struct AncestorNode {
ancestors: AncestorList,
}

struct AncestorList(Option<unstable::Exclusive<AncestorNode>>);
struct AncestorList(Option<Exclusive<AncestorNode>>);

// Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety.
#[inline(always)]
Expand All @@ -167,7 +168,7 @@ fn access_group<U>(x: &TaskGroupArc, blk: &fn(TaskGroupInner) -> U) -> U {
}

#[inline(always)]
fn access_ancestors<U>(x: &unstable::Exclusive<AncestorNode>,
fn access_ancestors<U>(x: &Exclusive<AncestorNode>,
blk: &fn(x: &mut AncestorNode) -> U) -> U {
x.with(blk)
}
Expand Down Expand Up @@ -479,7 +480,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
// here.
let mut members = new_taskset();
taskset_insert(&mut members, spawner);
let tasks = unstable::exclusive(Some(TaskGroupData {
let tasks = exclusive(Some(TaskGroupData {
members: members,
descendants: new_taskset(),
}));
Expand Down Expand Up @@ -508,7 +509,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
(g, a, spawner_group.is_main)
} else {
// Child is in a separate group from spawner.
let g = unstable::exclusive(Some(TaskGroupData {
let g = exclusive(Some(TaskGroupData {
members: new_taskset(),
descendants: new_taskset(),
}));
Expand All @@ -528,7 +529,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
};
assert!(new_generation < uint::max_value);
// Build a new node in the ancestor list.
AncestorList(Some(unstable::exclusive(AncestorNode {
AncestorList(Some(exclusive(AncestorNode {
generation: new_generation,
parent_group: Some(spawner_group.tasks.clone()),
ancestors: old_ancestors,
Expand Down
Loading

0 comments on commit ad5bfd6

Please sign in to comment.