Closed tomasol closed 6 months ago
Thanks for your feedback. tokio::time::sleep(Duration::ZERO)
is an no-op in the current simulation. yield_now
simply yields back to the scheduler and does not move time forward. Therefore, in your case, task2 is in a spin loop and the simulation is stuck.
I'll fix sleep
and make it behave consistent with tokio.
Having two tasks,
t1
sleeps in a loop with a non-zero duration,t2
withDuration::ZERO
, I observe thatt2
always wins andt1
does not make any progress. Switchingt2
toyield_now
instead ofsleep
has no effect. IRL it looks likesleep(Duration::ZERO)
always yields for at least 1 ms.