mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 11:21:14 +00:00
Improve cooperation from background jobs
This commit is contained in:
parent
bcf73eb4e4
commit
004a54c4ae
1 changed files with 10 additions and 0 deletions
10
src/queue.rs
10
src/queue.rs
|
@ -446,8 +446,18 @@ where
|
|||
|
||||
let mut hb = None;
|
||||
|
||||
let yield_limit = 8;
|
||||
let mut count = 0;
|
||||
|
||||
loop {
|
||||
tracing::trace!("heartbeat: looping");
|
||||
count += 1;
|
||||
count = count % yield_limit;
|
||||
|
||||
// yield every 8 iterations to be kind to other tasks
|
||||
if count == 0 {
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
|
||||
tokio::select! {
|
||||
output = &mut fut => {
|
||||
|
|
Loading…
Reference in a new issue