@@ -19,7 +19,7 @@ use hermit_sync::without_interrupts;
1919#[ cfg( any( feature = "tcp" , feature = "udp" ) ) ]
2020use smoltcp:: time:: Instant ;
2121
22- use crate :: arch:: core_local:: * ;
22+ use crate :: arch:: core_local;
2323use crate :: errno:: Errno ;
2424use crate :: executor:: task:: AsyncTask ;
2525use crate :: io;
@@ -94,16 +94,13 @@ impl Wake for TaskNotify {
9494}
9595
9696pub ( crate ) fn run ( ) {
97- let mut cx = Context :: from_waker ( Waker :: noop ( ) ) ;
98-
9997 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 ;
107104 }
108105 }
109106 } ) ;
@@ -118,7 +115,7 @@ pub(crate) fn spawn<F>(future: F)
118115where
119116 F : Future < Output = ( ) > + Send + ' static ,
120117{
121- without_interrupts ( || async_tasks ( ) . push_back ( AsyncTask :: new ( future) ) ) ;
118+ core_local :: ex ( ) . spawn ( AsyncTask :: new ( future) ) . detach ( ) ;
122119}
123120
124121pub fn init ( ) {
@@ -177,7 +174,7 @@ where
177174 } else {
178175 None
179176 } ;
180- core_scheduler ( ) . add_network_timer (
177+ core_local :: core_scheduler ( ) . add_network_timer (
181178 delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
182179 ) ;
183180 }
@@ -203,7 +200,7 @@ where
203200 } else {
204201 None
205202 } ;
206- core_scheduler ( ) . add_network_timer (
203+ core_local :: core_scheduler ( ) . add_network_timer (
207204 delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
208205 ) ;
209206 }
@@ -230,7 +227,7 @@ where
230227 } ;
231228
232229 if delay. unwrap_or ( 10_000_000 ) > 10_000 {
233- core_scheduler ( ) . add_network_timer (
230+ core_local :: core_scheduler ( ) . add_network_timer (
234231 delay. map ( |d| crate :: arch:: processor:: get_timer_ticks ( ) + d) ,
235232 ) ;
236233 let wakeup_time =
0 commit comments