mirror of https://github.com/stjepang/smol
Fix a scheduling fairness issue
This commit is contained in:
parent
f40acf640c
commit
12fe6b5938
|
@ -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!");
|
||||
|
|
|
@ -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!");
|
||||
|
|
|
@ -346,6 +346,7 @@ impl Worker {
|
|||
self.global.queue.push(err.into_inner()).unwrap();
|
||||
self.global.notify();
|
||||
}
|
||||
self.local.flush().unwrap();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue