Skip to content

Commit ae42318

Browse files
committed
core: Make some parts of task private
1 parent c2fc731 commit ae42318

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

src/libcore/task/local_data.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub unsafe fn local_data_modify<T: Owned>(
7878
}
7979

8080
#[test]
81-
pub fn test_tls_multitask() unsafe {
81+
fn test_tls_multitask() unsafe {
8282
fn my_key(_x: @~str) { }
8383
local_data_set(my_key, @~"parent data");
8484
do task::spawn unsafe {
@@ -94,15 +94,15 @@ pub fn test_tls_multitask() unsafe {
9494
}
9595

9696
#[test]
97-
pub fn test_tls_overwrite() unsafe {
97+
fn test_tls_overwrite() unsafe {
9898
fn my_key(_x: @~str) { }
9999
local_data_set(my_key, @~"first data");
100100
local_data_set(my_key, @~"next data"); // Shouldn't leak.
101101
assert *(local_data_get(my_key).get()) == ~"next data";
102102
}
103103

104104
#[test]
105-
pub fn test_tls_pop() unsafe {
105+
fn test_tls_pop() unsafe {
106106
fn my_key(_x: @~str) { }
107107
local_data_set(my_key, @~"weasel");
108108
assert *(local_data_pop(my_key).get()) == ~"weasel";
@@ -111,7 +111,7 @@ pub fn test_tls_pop() unsafe {
111111
}
112112

113113
#[test]
114-
pub fn test_tls_modify() unsafe {
114+
fn test_tls_modify() unsafe {
115115
fn my_key(_x: @~str) { }
116116
local_data_modify(my_key, |data| {
117117
match data {
@@ -130,7 +130,7 @@ pub fn test_tls_modify() unsafe {
130130
}
131131

132132
#[test]
133-
pub fn test_tls_crust_automorestack_memorial_bug() unsafe {
133+
fn test_tls_crust_automorestack_memorial_bug() unsafe {
134134
// This might result in a stack-canary clobber if the runtime fails to set
135135
// sp_limit to 0 when calling the cleanup extern - it might automatically
136136
// jump over to the rust stack, which causes next_c_sp to get recorded as
@@ -143,7 +143,7 @@ pub fn test_tls_crust_automorestack_memorial_bug() unsafe {
143143
}
144144

145145
#[test]
146-
pub fn test_tls_multiple_types() unsafe {
146+
fn test_tls_multiple_types() unsafe {
147147
fn str_key(_x: @~str) { }
148148
fn box_key(_x: @@()) { }
149149
fn int_key(_x: @int) { }
@@ -155,7 +155,7 @@ pub fn test_tls_multiple_types() unsafe {
155155
}
156156

157157
#[test]
158-
pub fn test_tls_overwrite_multiple_types() {
158+
fn test_tls_overwrite_multiple_types() {
159159
fn str_key(_x: @~str) { }
160160
fn box_key(_x: @@()) { }
161161
fn int_key(_x: @int) { }
@@ -171,7 +171,7 @@ pub fn test_tls_overwrite_multiple_types() {
171171
#[test]
172172
#[should_fail]
173173
#[ignore(cfg(windows))]
174-
pub fn test_tls_cleanup_on_failure() unsafe {
174+
fn test_tls_cleanup_on_failure() unsafe {
175175
fn str_key(_x: @~str) { }
176176
fn box_key(_x: @@()) { }
177177
fn int_key(_x: @int) { }

src/libcore/task/local_data_priv.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ impl LocalData: Eq {
1717

1818
// We use dvec because it's the best data structure in core. If TLS is used
1919
// heavily in future, this could be made more efficient with a proper map.
20-
pub type TaskLocalElement = (*libc::c_void, *libc::c_void, LocalData);
20+
type TaskLocalElement = (*libc::c_void, *libc::c_void, LocalData);
2121
// Has to be a pointer at outermost layer; the foreign call returns void *.
22-
pub type TaskLocalMap = @dvec::DVec<Option<TaskLocalElement>>;
22+
type TaskLocalMap = @dvec::DVec<Option<TaskLocalElement>>;
2323

24-
pub extern fn cleanup_task_local_map(map_ptr: *libc::c_void) unsafe {
24+
extern fn cleanup_task_local_map(map_ptr: *libc::c_void) unsafe {
2525
assert !map_ptr.is_null();
2626
// Get and keep the single reference that was created at the beginning.
2727
let _map: TaskLocalMap = cast::reinterpret_cast(&map_ptr);
2828
// All local_data will be destroyed along with the map.
2929
}
3030

3131
// Gets the map from the runtime. Lazily initialises if not done so already.
32-
pub unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
32+
unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
3333

3434
// Relies on the runtime initialising the pointer to null.
3535
// NOTE: The map's box lives in TLS invisibly referenced once. Each time
@@ -52,7 +52,7 @@ pub unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
5252
}
5353
}
5454

55-
pub unsafe fn key_to_key_value<T: Owned>(
55+
unsafe fn key_to_key_value<T: Owned>(
5656
key: LocalDataKey<T>) -> *libc::c_void {
5757

5858
// Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
@@ -62,7 +62,7 @@ pub unsafe fn key_to_key_value<T: Owned>(
6262
}
6363

6464
// If returning Some(..), returns with @T with the map's reference. Careful!
65-
pub unsafe fn local_data_lookup<T: Owned>(
65+
unsafe fn local_data_lookup<T: Owned>(
6666
map: TaskLocalMap, key: LocalDataKey<T>)
6767
-> Option<(uint, *libc::c_void)> {
6868

@@ -80,7 +80,7 @@ pub unsafe fn local_data_lookup<T: Owned>(
8080
}
8181
}
8282

83-
pub unsafe fn local_get_helper<T: Owned>(
83+
unsafe fn local_get_helper<T: Owned>(
8484
task: *rust_task, key: LocalDataKey<T>,
8585
do_pop: bool) -> Option<@T> {
8686

src/libcore/task/spawn.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ macro_rules! move_it (
6969
{ $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
7070
)
7171

72-
pub type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
72+
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
7373

74-
pub fn new_taskset() -> TaskSet {
74+
fn new_taskset() -> TaskSet {
7575
send_map::linear::LinearMap()
7676
}
77-
pub fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) {
77+
fn taskset_insert(tasks: &mut TaskSet, task: *rust_task) {
7878
let didnt_overwrite = tasks.insert(task, ());
7979
assert didnt_overwrite;
8080
}
81-
pub fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
81+
fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
8282
let was_present = tasks.remove(&task);
8383
assert was_present;
8484
}
@@ -87,20 +87,20 @@ pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) {
8787
}
8888

8989
// One of these per group of linked-failure tasks.
90-
pub type TaskGroupData = {
90+
type TaskGroupData = {
9191
// All tasks which might kill this group. When this is empty, the group
9292
// can be "GC"ed (i.e., its link in the ancestor list can be removed).
9393
mut members: TaskSet,
9494
// All tasks unidirectionally supervised by (directly or transitively)
9595
// tasks in this group.
9696
mut descendants: TaskSet,
9797
};
98-
pub type TaskGroupArc = private::Exclusive<Option<TaskGroupData>>;
98+
type TaskGroupArc = private::Exclusive<Option<TaskGroupData>>;
9999

100-
pub type TaskGroupInner = &mut Option<TaskGroupData>;
100+
type TaskGroupInner = &mut Option<TaskGroupData>;
101101

102102
// A taskgroup is 'dead' when nothing can cause it to fail; only members can.
103-
pub pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
103+
pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
104104
(&tg.members).is_empty()
105105
}
106106

@@ -111,7 +111,7 @@ pub pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
111111
// taskgroup which was spawned-unlinked. Tasks from intermediate generations
112112
// have references to the middle of the list; when intermediate generations
113113
// die, their node in the list will be collected at a descendant's spawn-time.
114-
pub type AncestorNode = {
114+
type AncestorNode = {
115115
// Since the ancestor list is recursive, we end up with references to
116116
// exclusives within other exclusives. This is dangerous business (if
117117
// circular references arise, deadlock and memory leaks are imminent).
@@ -124,16 +124,16 @@ pub type AncestorNode = {
124124
// Recursive rest of the list.
125125
mut ancestors: AncestorList,
126126
};
127-
pub enum AncestorList = Option<private::Exclusive<AncestorNode>>;
127+
enum AncestorList = Option<private::Exclusive<AncestorNode>>;
128128

129129
// Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety.
130130
#[inline(always)]
131-
pub fn access_group<U>(x: &TaskGroupArc, blk: fn(TaskGroupInner) -> U) -> U {
131+
fn access_group<U>(x: &TaskGroupArc, blk: fn(TaskGroupInner) -> U) -> U {
132132
unsafe { x.with(blk) }
133133
}
134134

135135
#[inline(always)]
136-
pub fn access_ancestors<U>(x: &private::Exclusive<AncestorNode>,
136+
fn access_ancestors<U>(x: &private::Exclusive<AncestorNode>,
137137
blk: fn(x: &mut AncestorNode) -> U) -> U {
138138
unsafe { x.with(blk) }
139139
}
@@ -146,7 +146,7 @@ pub fn access_ancestors<U>(x: &private::Exclusive<AncestorNode>,
146146
// (3) As a bonus, coalesces away all 'dead' taskgroup nodes in the list.
147147
// FIXME(#2190): Change Option<fn@(...)> to Option<fn&(...)>, to save on
148148
// allocations. Once that bug is fixed, changing the sigil should suffice.
149-
pub fn each_ancestor(list: &mut AncestorList,
149+
fn each_ancestor(list: &mut AncestorList,
150150
bail_opt: Option<fn@(TaskGroupInner)>,
151151
forward_blk: fn(TaskGroupInner) -> bool)
152152
-> bool {
@@ -271,7 +271,7 @@ pub fn each_ancestor(list: &mut AncestorList,
271271
}
272272

273273
// One of these per task.
274-
pub struct TCB {
274+
struct TCB {
275275
me: *rust_task,
276276
// List of tasks with whose fates this one's is intertwined.
277277
tasks: TaskGroupArc, // 'none' means the group has failed.
@@ -303,7 +303,7 @@ pub struct TCB {
303303
}
304304
}
305305

306-
pub fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
306+
fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
307307
is_main: bool, notifier: Option<AutoNotify>) -> TCB {
308308

309309
let notifier = move notifier;
@@ -318,7 +318,7 @@ pub fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
318318
}
319319
}
320320

321-
pub struct AutoNotify {
321+
struct AutoNotify {
322322
notify_chan: Chan<Notification>,
323323
mut failed: bool,
324324
drop {
@@ -327,14 +327,14 @@ pub struct AutoNotify {
327327
}
328328
}
329329

330-
pub fn AutoNotify(chan: Chan<Notification>) -> AutoNotify {
330+
fn AutoNotify(chan: Chan<Notification>) -> AutoNotify {
331331
AutoNotify {
332332
notify_chan: chan,
333333
failed: true // Un-set above when taskgroup successfully made.
334334
}
335335
}
336336

337-
pub fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
337+
fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
338338
is_member: bool) -> bool {
339339
let newstate = util::replace(state, None);
340340
// If 'None', the group was failing. Can't enlist.
@@ -350,7 +350,7 @@ pub fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task,
350350
}
351351

352352
// NB: Runs in destructor/post-exit context. Can't 'fail'.
353-
pub fn leave_taskgroup(state: TaskGroupInner, me: *rust_task,
353+
fn leave_taskgroup(state: TaskGroupInner, me: *rust_task,
354354
is_member: bool) {
355355
let newstate = util::replace(state, None);
356356
// If 'None', already failing and we've already gotten a kill signal.
@@ -363,7 +363,7 @@ pub fn leave_taskgroup(state: TaskGroupInner, me: *rust_task,
363363
}
364364

365365
// NB: Runs in destructor/post-exit context. Can't 'fail'.
366-
pub fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) {
366+
fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) {
367367
// NB: We could do the killing iteration outside of the group arc, by
368368
// having "let mut newstate" here, swapping inside, and iterating after.
369369
// But that would let other exiting tasks fall-through and exit while we
@@ -405,7 +405,7 @@ macro_rules! taskgroup_key (
405405
() => (cast::transmute((-2 as uint, 0u)))
406406
)
407407

408-
pub fn gen_child_taskgroup(linked: bool, supervised: bool)
408+
fn gen_child_taskgroup(linked: bool, supervised: bool)
409409
-> (TaskGroupArc, AncestorList, bool) {
410410
let spawner = rt::rust_get_task();
411411
/*######################################################################*

0 commit comments

Comments
 (0)