Fix a scheduling fairness issue

This commit is contained in:
Stjepan Glavina 2020-06-20 16:29:04 +02:00
parent f40acf640c
commit 12fe6b5938
4 changed files with 9 additions and 5 deletions

View File

@ -20,7 +20,7 @@ fn main() {
smol::run(async {
println!("Waiting for Ctrl-C...");
// Receive a message that indicates the Ctrl-C signal occured.
// Receive a message that indicates the Ctrl-C signal occurred.
ctrl_c.recv().await;
println!("Done!");

View File

@ -20,7 +20,7 @@ fn main() -> std::io::Result<()> {
signal_hook::pipe::register(signal_hook::SIGINT, a)?;
println!("Waiting for Ctrl-C...");
// Receive a byte that indicates the Ctrl-C signal occured.
// Receive a byte that indicates the Ctrl-C signal occurred.
b.read_exact(&mut [0]).await?;
println!("Done!");

View File

@ -346,6 +346,7 @@ impl Worker {
self.global.queue.push(err.into_inner()).unwrap();
self.global.notify();
}
self.local.flush().unwrap();
}
return true;

View File

@ -251,13 +251,16 @@ impl ReactorLock<'_> {
// Block on I/O events.
match self.reactor.sys.wait(&mut self.events, timeout) {
// The timeout was hit so fire ready timers.
// No I/O events occurred.
Ok(0) => {
self.reactor.fire_timers();
if timeout != Some(Duration::from_secs(0)) {
// The non-zero timeout was hit so fire ready timers.
self.reactor.fire_timers();
}
Ok(())
}
// At least one I/O event occured.
// At least one I/O event occurred.
Ok(_) => {
// Iterate over sources in the event list.
let sources = self.reactor.sources.lock();