We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 50b4b89 commit e465c5bCopy full SHA for e465c5b
src/task/executor.rs
@@ -32,6 +32,7 @@ impl Executor {
32
loop {
33
self.wake_tasks();
34
self.run_ready_tasks();
35
+ self.sleep_if_idle();
36
}
37
38
@@ -65,6 +66,22 @@ impl Executor {
65
66
67
68
69
+ fn sleep_if_idle(&self) {
70
+ use x86_64::instructions::interrupts::{self, enable_interrupts_and_hlt};
71
+
72
+ // fast path
73
+ if !self.wake_queue.is_empty() {
74
+ return;
75
+ }
76
77
+ interrupts::disable();
78
+ if self.wake_queue.is_empty() {
79
+ enable_interrupts_and_hlt();
80
+ } else {
81
+ interrupts::enable();
82
83
84
85
fn create_waker(&self, task_id: TaskId) -> Waker {
86
Waker::from(Arc::new(TaskWaker {
87
task_id,
0 commit comments