Skip to content

Commit b548c78

Browse files
committed
Merge pull request #3 from toddaaro/io
Updated a match expression to use an enum instead of dispatching on an integer
2 parents 29ad8e1 + 753b497 commit b548c78

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/libstd/rt/sched.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -381,52 +381,44 @@ impl Scheduler {
381381
match home {
382382
&Some(Sched(ref home_handle))
383383
if home_handle.sched_id != this.sched_id() => {
384-
0
384+
SendHome
385385
}
386386
&Some(AnySched) if this.run_anything => {
387-
1
387+
ResumeNow
388388
}
389389
&Some(AnySched) => {
390-
2
390+
Requeue
391391
}
392392
&Some(Sched(_)) => {
393-
3
393+
ResumeNow
394394
}
395395
&None => {
396-
4
396+
Homeless
397397
}
398398
}
399399
};
400400

401401
match action_id {
402-
0 => {
402+
SendHome => {
403403
rtdebug!("sending task home");
404404
Scheduler::send_task_home(task);
405405
Local::put(this);
406406
return false;
407407
}
408-
1 => {
408+
ResumeNow => {
409409
rtdebug!("resuming now");
410410
this.resume_task_immediately(task);
411411
return true;
412412
}
413-
2 => {
413+
Requeue => {
414414
rtdebug!("re-queueing")
415415
this.enqueue_task(task);
416416
Local::put(this);
417417
return false;
418418
}
419-
3 => {
420-
rtdebug!("resuming now");
421-
this.resume_task_immediately(task);
422-
return true;
423-
}
424-
4 => {
419+
Homeless => {
425420
rtabort!("task home was None!");
426421
}
427-
_ => {
428-
rtabort!("literally, you should not be here");
429-
}
430422
}
431423
}
432424

@@ -654,6 +646,14 @@ impl Scheduler {
654646
}
655647
}
656648

649+
// The cases for the below function.
650+
enum ResumeAction {
651+
SendHome,
652+
Requeue,
653+
ResumeNow,
654+
Homeless
655+
}
656+
657657
impl SchedHandle {
658658
pub fn send(&mut self, msg: SchedMessage) {
659659
self.queue.push(msg);

0 commit comments

Comments
 (0)