Skip to content

Commit 42825fb

Browse files
committed
Split libcore/arc.rs: arc -> std::arc; exclusive -> unsafe::exclusive
1 parent 4808d59 commit 42825fb

File tree

12 files changed

+319
-272
lines changed

12 files changed

+319
-272
lines changed

src/libcore/arc.rs

Lines changed: 0 additions & 219 deletions
This file was deleted.

src/libcore/core.rc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export float, f32, f64;
3939
export box, char, str, ptr, vec, at_vec, bool;
4040
export either, option, result, iter;
4141
export libc, os, io, run, rand, sys, unsafe, logging;
42-
export arc, comm, task, future, pipes, sync;
42+
export comm, task, future, pipes;
4343
export extfmt;
4444
// The test harness links against core, so don't include runtime in tests.
4545
// FIXME (#2861): Uncomment this after snapshot gets updated.
@@ -199,12 +199,10 @@ mod dlist_iter {
199199
mod send_map;
200200

201201
// Concurrency
202-
mod arc;
203202
mod comm;
204203
mod task;
205204
mod future;
206205
mod pipes;
207-
mod sync;
208206

209207
// Runtime and language-primitive support
210208

src/libcore/pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ impl<T: send> port<T>: selectable {
10641064
}
10651065

10661066
/// A channel that can be shared between many senders.
1067-
type shared_chan<T: send> = arc::exclusive<chan<T>>;
1067+
type shared_chan<T: send> = unsafe::exclusive<chan<T>>;
10681068

10691069
impl<T: send> shared_chan<T>: channel<T> {
10701070
fn send(+x: T) {
@@ -1088,7 +1088,7 @@ impl<T: send> shared_chan<T>: channel<T> {
10881088

10891089
/// Converts a `chan` into a `shared_chan`.
10901090
fn shared_chan<T:send>(+c: chan<T>) -> shared_chan<T> {
1091-
arc::exclusive(c)
1091+
unsafe::exclusive(c)
10921092
}
10931093

10941094
/// Receive a message from one of two endpoints.

src/libcore/sys.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,17 @@ export min_align_of;
77
export pref_align_of;
88
export refcount;
99
export log_str;
10-
export little_lock, methods;
1110
export shape_eq, shape_lt, shape_le;
1211

13-
import task::atomically;
14-
1512
enum type_desc = {
1613
size: uint,
1714
align: uint
1815
// Remaining fields not listed
1916
};
2017

21-
type rust_little_lock = *libc::c_void;
22-
2318
#[abi = "cdecl"]
2419
extern mod rustrt {
2520
pure fn shape_log_str(t: *sys::type_desc, data: *()) -> ~str;
26-
27-
fn rust_create_little_lock() -> rust_little_lock;
28-
fn rust_destroy_little_lock(lock: rust_little_lock);
29-
fn rust_lock_little_lock(lock: rust_little_lock);
30-
fn rust_unlock_little_lock(lock: rust_little_lock);
3121
}
3222

3323
#[abi = "rust-intrinsic"]
@@ -98,30 +88,6 @@ pure fn log_str<T>(t: T) -> ~str {
9888
}
9989
}
10090

101-
class little_lock {
102-
let l: rust_little_lock;
103-
new() {
104-
self.l = rustrt::rust_create_little_lock();
105-
}
106-
drop { rustrt::rust_destroy_little_lock(self.l); }
107-
}
108-
109-
impl little_lock {
110-
unsafe fn lock<T>(f: fn() -> T) -> T {
111-
class unlock {
112-
let l: rust_little_lock;
113-
new(l: rust_little_lock) { self.l = l; }
114-
drop { rustrt::rust_unlock_little_lock(self.l); }
115-
}
116-
117-
do atomically {
118-
rustrt::rust_lock_little_lock(self.l);
119-
let _r = unlock(self.l);
120-
f()
121-
}
122-
}
123-
}
124-
12591
#[cfg(test)]
12692
mod tests {
12793

src/libcore/task.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ unsafe fn atomically<U>(f: fn() -> U) -> U {
625625
* Several data structures are involved in task management to allow properly
626626
* propagating failure across linked/supervised tasks.
627627
*
628-
* (1) The "taskgroup_arc" is an arc::exclusive which contains a hashset of
628+
* (1) The "taskgroup_arc" is an unsafe::exclusive which contains a hashset of
629629
* all tasks that are part of the group. Some tasks are 'members', which
630630
* means if they fail, they will kill everybody else in the taskgroup.
631631
* Other tasks are 'descendants', which means they will not kill tasks
@@ -639,7 +639,7 @@ unsafe fn atomically<U>(f: fn() -> U) -> U {
639639
* whether it's part of the 'main'/'root' taskgroup, and an optionally
640640
* configured notification port. These are stored in TLS.
641641
*
642-
* (3) The "ancestor_list" is a cons-style list of arc::exclusives which
642+
* (3) The "ancestor_list" is a cons-style list of unsafe::exclusives which
643643
* tracks 'generations' of taskgroups -- a group's ancestors are groups
644644
* which (directly or transitively) spawn_supervised-ed them. Each task
645645
* is recorded in the 'descendants' of each of its ancestor groups.
@@ -725,7 +725,7 @@ type taskgroup_data = {
725725
// tasks in this group.
726726
mut descendants: taskset,
727727
};
728-
type taskgroup_arc = arc::exclusive<option<taskgroup_data>>;
728+
type taskgroup_arc = unsafe::exclusive<option<taskgroup_data>>;
729729

730730
type taskgroup_inner = &mut option<taskgroup_data>;
731731

@@ -754,15 +754,15 @@ type ancestor_node = {
754754
// Recursive rest of the list.
755755
mut ancestors: ancestor_list,
756756
};
757-
enum ancestor_list = option<arc::exclusive<ancestor_node>>;
757+
enum ancestor_list = option<unsafe::exclusive<ancestor_node>>;
758758

759759
// Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety.
760760
#[inline(always)]
761761
fn access_group<U>(x: taskgroup_arc, blk: fn(taskgroup_inner) -> U) -> U {
762762
unsafe { x.with(blk) }
763763
}
764764
#[inline(always)]
765-
fn access_ancestors<U>(x: arc::exclusive<ancestor_node>,
765+
fn access_ancestors<U>(x: unsafe::exclusive<ancestor_node>,
766766
blk: fn(x: &mut ancestor_node) -> U) -> U {
767767
unsafe { x.with(blk) }
768768
}
@@ -1035,8 +1035,8 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
10351035
let mut members = new_taskset();
10361036
taskset_insert(&mut members, spawner);
10371037
let tasks =
1038-
arc::exclusive(some({ mut members: members,
1039-
mut descendants: new_taskset() }));
1038+
unsafe::exclusive(some({ mut members: members,
1039+
mut descendants: new_taskset() }));
10401040
// Main task/group has no ancestors, no notifier, etc.
10411041
let group =
10421042
@tcb(spawner, tasks, ancestor_list(none), true, none);
@@ -1057,8 +1057,8 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
10571057
(g, a, spawner_group.is_main)
10581058
} else {
10591059
// Child is in a separate group from spawner.
1060-
let g = arc::exclusive(some({ mut members: new_taskset(),
1061-
mut descendants: new_taskset() }));
1060+
let g = unsafe::exclusive(some({ mut members: new_taskset(),
1061+
mut descendants: new_taskset() }));
10621062
let a = if supervised {
10631063
// Child's ancestors start with the spawner.
10641064
let old_ancestors = share_ancestors(&mut spawner_group.ancestors);
@@ -1072,7 +1072,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
10721072
};
10731073
assert new_generation < uint::max_value;
10741074
// Build a new node in the ancestor list.
1075-
ancestor_list(some(arc::exclusive(
1075+
ancestor_list(some(unsafe::exclusive(
10761076
{ generation: new_generation,
10771077
mut parent_group: some(spawner_group.tasks.clone()),
10781078
mut ancestors: old_ancestors })))

0 commit comments

Comments
 (0)