@@ -29,6 +29,9 @@ use rt::rtio::{IoFactoryObject, RemoteCallback};
29
29
/// on a single thread. When the scheduler is running it is owned by
30
30
/// thread local storage and the running task is owned by the
31
31
/// scheduler.
32
+ ///
33
+ /// XXX: This creates too many callbacks to run_sched_once, resulting
34
+ /// in too much allocation and too many events.
32
35
pub struct Scheduler {
33
36
/// A queue of available work. Under a work-stealing policy there
34
37
/// is one per Scheduler.
@@ -143,6 +146,10 @@ pub impl Scheduler {
143
146
144
147
fn run_sched_once ( ) {
145
148
149
+ // First, check the message queue for instructions.
150
+ // XXX: perf. Check for messages without atomics.
151
+ // It's ok if we miss messages occasionally, as long as
152
+ // we sync and check again before sleeping.
146
153
let sched = Local :: take :: < Scheduler > ( ) ;
147
154
if sched. interpret_message_queue ( ) {
148
155
// We performed a scheduling action. There may be other work
@@ -153,6 +160,7 @@ pub impl Scheduler {
153
160
return ;
154
161
}
155
162
163
+ // Now, look in the work queue for tasks to run
156
164
let sched = Local :: take :: < Scheduler > ( ) ;
157
165
if sched. resume_task_from_queue ( ) {
158
166
// We performed a scheduling action. There may be other work
@@ -198,6 +206,12 @@ pub impl Scheduler {
198
206
self . event_loop . callback ( Scheduler :: run_sched_once) ;
199
207
200
208
// We've made work available. Notify a sleeping scheduler.
209
+ // XXX: perf. Check for a sleeper without synchronizing memory.
210
+ // It's not critical that we always find it.
211
+ // XXX: perf. If there's a sleeper then we might as well just send
212
+ // it the task directly instead of pushing it to the
213
+ // queue. That is essentially the intent here and it is less
214
+ // work.
201
215
match self . sleeper_list . pop ( ) {
202
216
Some ( handle) => {
203
217
let mut handle = handle;
0 commit comments