mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 11:21:24 +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 mut hb = None;
|
||||||
|
|
||||||
|
let yield_limit = 8;
|
||||||
|
let mut count = 0;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
tracing::trace!("heartbeat: looping");
|
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! {
|
tokio::select! {
|
||||||
output = &mut fut => {
|
output = &mut fut => {
|
||||||
|
|
Loading…
Reference in a new issue