1
0
Fork 0
forked from wry/wry

async_engine: slightly optimize dispatch

This commit is contained in:
Julian Orth 2024-09-13 12:30:26 +02:00
parent 297a6e58cd
commit 0ccc1a2391

View file

@ -97,7 +97,7 @@ impl AsyncEngine {
continue; continue;
} }
self.num_queued.fetch_sub(stash.len()); self.num_queued.fetch_sub(stash.len());
for runnable in stash.drain(..) { while let Some(runnable) = stash.pop_front() {
runnable.run(); runnable.run();
if self.stopped.get() { if self.stopped.get() {
return; return;
@ -105,7 +105,7 @@ impl AsyncEngine {
} }
} }
self.yields.swap(&mut *yield_stash); self.yields.swap(&mut *yield_stash);
for waker in yield_stash.drain(..) { while let Some(waker) = yield_stash.pop_front() {
waker.wake(); waker.wake();
} }
} }