@@ -19,7 +19,7 @@ use hermit_sync::without_interrupts;
19
19
#[ cfg( any( feature = "tcp" , feature = "udp" ) ) ]
20
20
use smoltcp:: time:: Instant ;
21
21
22
- use crate :: arch:: core_local:: * ;
22
+ use crate :: arch:: core_local;
23
23
use crate :: errno:: Errno ;
24
24
use crate :: executor:: task:: AsyncTask ;
25
25
use crate :: io;
@@ -94,16 +94,13 @@ impl Wake for TaskNotify {
94
94
}
95
95
96
96
pub ( crate ) fn run ( ) {
97
- let mut cx = Context :: from_waker ( Waker :: noop ( ) ) ;
98
-
99
97
without_interrupts ( || {
100
- // FIXME(mkroening): Not all tasks register wakers and never sleep
101
- for _ in 0 ..( { async_tasks ( ) . len ( ) } ) {
102
- let mut task = { async_tasks ( ) . pop_front ( ) . unwrap ( ) } ;
103
- trace ! ( "Run async task {}" , task. id( ) ) ;
104
-
105
- if task. poll ( & mut cx) . is_pending ( ) {
106
- async_tasks ( ) . push_back ( task) ;
98
+ // FIXME: We currently have no more than 3 tasks at a time, so this is fine.
99
+ // Ideally, we would set this value to 200, but the network task currently immediately wakes up again.
100
+ // This would lead to the network task being polled 200 times back to back, slowing things down considerably.
101
+ for _ in 0 ..3 {
102
+ if !core_local:: ex ( ) . try_tick ( ) {
103
+ break ;
107
104
}
108
105
}
109
106
} ) ;
@@ -118,7 +115,7 @@ pub(crate) fn spawn<F>(future: F)
118
115
where
119
116
F : Future < Output = ( ) > + Send + ' static ,
120
117
{
121
- without_interrupts ( || async_tasks ( ) . push_back ( AsyncTask :: new ( future) ) ) ;
118
+ core_local :: ex ( ) . spawn ( AsyncTask :: new ( future) ) . detach ( ) ;
122
119
}
123
120
124
121
pub fn init ( ) {
@@ -177,7 +174,7 @@ where
177
174
} else {
178
175
None
179
176
} ;
180
- core_scheduler ( ) . add_network_timer (
177
+ core_local :: core_scheduler ( ) . add_network_timer (
181
178
delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
182
179
) ;
183
180
}
@@ -203,7 +200,7 @@ where
203
200
} else {
204
201
None
205
202
} ;
206
- core_scheduler ( ) . add_network_timer (
203
+ core_local :: core_scheduler ( ) . add_network_timer (
207
204
delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
208
205
) ;
209
206
}
@@ -230,7 +227,7 @@ where
230
227
} ;
231
228
232
229
if delay. unwrap_or ( 10_000_000 ) > 10_000 {
233
- core_scheduler ( ) . add_network_timer (
230
+ core_local :: core_scheduler ( ) . add_network_timer (
234
231
delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
235
232
) ;
236
233
let wakeup_time =
0 commit comments