@@ -60,6 +60,7 @@ impl HackAroundBorrowCk for UnsafeTaskReceiver {
60
60
}
61
61
62
62
enum CleanupJob {
63
+ DoNothing ,
63
64
RescheduleTask ( ~Task ) ,
64
65
RecycleTask ( ~Task ) ,
65
66
GiveTask ( ~Task , UnsafeTaskReceiver )
@@ -148,6 +149,7 @@ pub impl Scheduler {
148
149
149
150
// Store the task in the scheduler so it can be grabbed later
150
151
self . current_task = Some ( task) ;
152
+ self . enqueue_cleanup_job ( DoNothing ) ;
151
153
152
154
// Take pointers to both the task and scheduler's saved registers.
153
155
{
@@ -243,14 +245,13 @@ pub impl Scheduler {
243
245
}
244
246
245
247
fn run_cleanup_job ( & mut self ) {
246
- rtdebug ! ( "running cleanup jobs " ) ;
248
+ rtdebug ! ( "running cleanup job " ) ;
247
249
248
- if self . cleanup_job . is_none ( ) {
249
- return ;
250
- }
250
+ assert ! ( self . cleanup_job. is_some( ) ) ;
251
251
252
252
let cleanup_job = self . cleanup_job . swap_unwrap ( ) ;
253
253
match cleanup_job {
254
+ DoNothing => { }
254
255
RescheduleTask ( task) => {
255
256
// NB: Pushing to the *front* of the queue
256
257
self . task_queue . push_front ( task) ;
@@ -278,9 +279,10 @@ pub impl Scheduler {
278
279
Some ( GiveTask ( ~ref task, _) ) => {
279
280
Some ( task)
280
281
}
281
- None => {
282
+ Some ( DoNothing ) => {
282
283
None
283
284
}
285
+ None => fail ! ( fmt!( "all context switches should have a cleanup job" ) )
284
286
} ;
285
287
// XXX: Pattern matching mutable pointers above doesn't work
286
288
// because borrowck thinks the three patterns are conflicting
0 commit comments