Skip to content

Commit 1edfbc2

Browse files
committed
---
yaml --- r: 143015 b: refs/heads/try2 c: 6d91846 h: refs/heads/master i: 143013: a195832 143011: d364bd4 143007: 44a6b24 v: v3
1 parent b9302f9 commit 1edfbc2

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 87bbcb579a170f4d2c36df4370703075c81b0b5d
8+
refs/heads/try2: 6d9184609a6edb54eb06f402dedcbc8f13da3d1a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/task/spawn.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ struct AncestorNode {
176176
// circular references arise, deadlock and memory leaks are imminent).
177177
// Hence we assert that this counter monotonically decreases as we
178178
// approach the tail of the list.
179-
// FIXME(#3068): Make the generation counter togglable with #[cfg(debug)].
180179
generation: uint,
181180
// Handle to the tasks in the group of the current generation.
182181
parent_group: TaskGroupArc,
@@ -202,6 +201,18 @@ fn access_ancestors<U>(x: &Exclusive<AncestorNode>,
202201
}
203202
}
204203

204+
#[inline] #[cfg(test)]
205+
fn check_generation(younger: uint, older: uint) { assert!(younger > older); }
206+
#[inline] #[cfg(not(test))]
207+
fn check_generation(_younger: uint, _older: uint) { }
208+
209+
#[inline] #[cfg(test)]
210+
fn incr_generation(ancestors: &AncestorList) -> uint {
211+
ancestors.map_default(0, |arc| access_ancestors(arc, |a| a.generation+1))
212+
}
213+
#[inline] #[cfg(not(test))]
214+
fn incr_generation(_ancestors: &AncestorList) -> uint { 0 }
215+
205216
// Iterates over an ancestor list.
206217
// (1) Runs forward_blk on each ancestral taskgroup in the list
207218
// (2) If forward_blk "break"s, runs optional bail_blk on all ancestral
@@ -264,7 +275,7 @@ fn each_ancestor(list: &mut AncestorList,
264275
// Argh, but we couldn't give it to coalesce() otherwise.
265276
let forward_blk = forward_blk.take();
266277
// Check monotonicity
267-
assert!(last_generation > nobe.generation);
278+
check_generation(last_generation, nobe.generation);
268279
/*##########################################################*
269280
* Step 1: Look at this ancestor group (call iterator block).
270281
*##########################################################*/
@@ -594,16 +605,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
594605
descendants: new_taskset(),
595606
}));
596607
let a = if supervised {
597-
// FIXME(#3068) - The generation counter is only used for a
598-
// debug assertion, but initialising it requires locking a
599-
// mutex. Hence it should be enabled only in debug builds.
600-
let new_generation =
601-
match *ancestors {
602-
Some(ref arc) => {
603-
access_ancestors(arc, |a| a.generation+1)
604-
}
605-
None => 0 // the actual value doesn't really matter.
606-
};
608+
let new_generation = incr_generation(&ancestors);
607609
assert!(new_generation < uint::max_value);
608610
// Child's ancestors start with the spawner.
609611
// Build a new node in the ancestor list.
@@ -710,8 +712,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
710712
let child_data = Cell::new((child_tg, ancestors, f));
711713
// Being killed with the unsafe task/closure pointers would leak them.
712714
do unkillable {
713-
// Agh. Get move-mode items into the closure. FIXME (#2829)
714-
let (child_tg, ancestors, f) = child_data.take();
715+
let (child_tg, ancestors, f) = child_data.take(); // :(
715716
// Create child task.
716717
let new_task = match opts.sched.mode {
717718
DefaultScheduler => rt::new_task(),
@@ -745,8 +746,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
745746
-> ~fn() {
746747
let child_data = Cell::new((notify_chan, child_arc, ancestors));
747748
let result: ~fn() = || {
748-
// Agh. Get move-mode items into the closure. FIXME (#2829)
749-
let (notify_chan, child_arc, ancestors) = child_data.take();
749+
let (notify_chan, child_arc, ancestors) = child_data.take(); // :(
750750
let mut ancestors = ancestors;
751751
// Child task runs this code.
752752

0 commit comments

Comments
 (0)