Skip to content

Cleanup unsafe synchronization primitives in core #6387

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 3 commits into from
May 13, 2013
Merged
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
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 @@ -860,7 +860,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