@@ -176,7 +176,6 @@ struct AncestorNode {
176
176
// circular references arise, deadlock and memory leaks are imminent).
177
177
// Hence we assert that this counter monotonically decreases as we
178
178
// approach the tail of the list.
179
- // FIXME(#3068): Make the generation counter togglable with #[cfg(debug)].
180
179
generation : uint ,
181
180
// Handle to the tasks in the group of the current generation.
182
181
parent_group : TaskGroupArc ,
@@ -202,6 +201,18 @@ fn access_ancestors<U>(x: &Exclusive<AncestorNode>,
202
201
}
203
202
}
204
203
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
+
205
216
// Iterates over an ancestor list.
206
217
// (1) Runs forward_blk on each ancestral taskgroup in the list
207
218
// (2) If forward_blk "break"s, runs optional bail_blk on all ancestral
@@ -264,7 +275,7 @@ fn each_ancestor(list: &mut AncestorList,
264
275
// Argh, but we couldn't give it to coalesce() otherwise.
265
276
let forward_blk = forward_blk. take ( ) ;
266
277
// Check monotonicity
267
- assert ! ( last_generation > nobe. generation) ;
278
+ check_generation ( last_generation, nobe. generation ) ;
268
279
/*##########################################################*
269
280
* Step 1: Look at this ancestor group (call iterator block).
270
281
*##########################################################*/
@@ -594,16 +605,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
594
605
descendants : new_taskset ( ) ,
595
606
} ) ) ;
596
607
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) ;
607
609
assert ! ( new_generation < uint:: max_value) ;
608
610
// Child's ancestors start with the spawner.
609
611
// Build a new node in the ancestor list.
@@ -710,8 +712,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
710
712
let child_data = Cell :: new ( ( child_tg, ancestors, f) ) ;
711
713
// Being killed with the unsafe task/closure pointers would leak them.
712
714
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 ( ) ; // :(
715
716
// Create child task.
716
717
let new_task = match opts. sched . mode {
717
718
DefaultScheduler => rt:: new_task ( ) ,
@@ -745,8 +746,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
745
746
-> ~fn ( ) {
746
747
let child_data = Cell :: new ( ( notify_chan, child_arc, ancestors) ) ;
747
748
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 ( ) ; // :(
750
750
let mut ancestors = ancestors;
751
751
// Child task runs this code.
752
752
0 commit comments