@@ -455,11 +455,11 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
455
455
Some ( Ok ( Err ( listen_to_done_event ( this, reader, done_event) ) ) )
456
456
}
457
457
Some ( InProgressState :: InProgress ( box InProgressStateInner {
458
- marked_as_completed ,
458
+ completed ,
459
459
done_event,
460
460
..
461
461
} ) ) => {
462
- if !* marked_as_completed {
462
+ if !* completed {
463
463
Some ( Ok ( Err ( listen_to_done_event ( this, reader, done_event) ) ) )
464
464
} else {
465
465
None
@@ -604,10 +604,22 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
604
604
} ;
605
605
606
606
// Output doesn't exist. We need to schedule the task to compute it.
607
- let ( item, listener) =
608
- CachedDataItem :: new_scheduled_with_listener ( self . get_task_desc_fn ( task_id) , note) ;
609
- task. add_new ( item) ;
610
- turbo_tasks. schedule ( task_id) ;
607
+ let listener = if let Some ( in_progress) = get_mut ! ( task, InProgress ) {
608
+ let InProgressState :: InProgress ( box InProgressStateInner {
609
+ done_event, stale, ..
610
+ } ) = in_progress
611
+ else {
612
+ unreachable ! ( ) ;
613
+ } ;
614
+ * stale = true ;
615
+ done_event. listen_with_note ( note)
616
+ } else {
617
+ let ( item, listener) =
618
+ CachedDataItem :: new_scheduled_with_listener ( self . get_task_desc_fn ( task_id) , note) ;
619
+ task. add_new ( item) ;
620
+ turbo_tasks. schedule ( task_id) ;
621
+ listener
622
+ } ;
611
623
612
624
Ok ( Err ( listener) )
613
625
}
@@ -1135,6 +1147,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1135
1147
done_event,
1136
1148
session_dependent : false ,
1137
1149
marked_as_completed : false ,
1150
+ completed : false ,
1138
1151
new_children : Default :: default ( ) ,
1139
1152
} ) ) ,
1140
1153
} ) ;
@@ -1277,7 +1290,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1277
1290
} ;
1278
1291
let & mut InProgressState :: InProgress ( box InProgressStateInner {
1279
1292
stale,
1280
- ref mut marked_as_completed ,
1293
+ ref mut completed ,
1281
1294
ref done_event,
1282
1295
ref mut new_children,
1283
1296
..
@@ -1318,10 +1331,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1318
1331
}
1319
1332
1320
1333
// mark the task as completed, so dependent tasks can continue working
1321
- if !* marked_as_completed {
1322
- * marked_as_completed = true ;
1323
- done_event. notify ( usize:: MAX ) ;
1324
- }
1334
+ * completed = true ;
1335
+ done_event. notify ( usize:: MAX ) ;
1325
1336
1326
1337
// take the children from the task to process them
1327
1338
let mut new_children = take ( new_children) ;
@@ -1498,6 +1509,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1498
1509
once_task : _,
1499
1510
stale,
1500
1511
session_dependent,
1512
+ completed : _,
1501
1513
marked_as_completed : _,
1502
1514
new_children,
1503
1515
} ) = in_progress
@@ -1882,12 +1894,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
1882
1894
let mut task = ctx. task ( task, TaskDataCategory :: Data ) ;
1883
1895
if let Some ( InProgressState :: InProgress ( box InProgressStateInner {
1884
1896
marked_as_completed,
1885
- done_event,
1886
1897
..
1887
1898
} ) ) = get_mut ! ( task, InProgress )
1888
1899
{
1889
1900
* marked_as_completed = true ;
1890
- done_event. notify ( usize:: MAX ) ;
1891
1901
// TODO this should remove the dirty state (also check session_dependent)
1892
1902
// but this would break some assumptions for strongly consistent reads.
1893
1903
// Client tasks are not connected yet, so we wouldn't wait for them.
0 commit comments