Some tokio nested tasks run several time more than other

For sure I will read its document just now,

Thank you,

The watch channel is single-producer, but you can put the single producer behind the same mutex as the channel contents, as you need to lock it when sending anyway. When you have nothing to do, you can use Tokio's select! macro to wait until more stuff arrives.

tokio::select! {
    _ = watch_receiver.recv() => {},
    _ = delay_until(minimum_next_run) => {} // or something involving `DelayQueue`
}

The expression above would wait until either something is broadcasted on the watch channel, or until the timeout expires and the next item is ready.

Hi Alice,

I read documents about your suggested guides to find which one is suitable to my code. I found all of them useful for when I want to tune the code for a better performance but the main key point you reminded me was considering about time that every method or function spend.
So I started checking elapsed time by microseconds in all methods and found my main fault was a change in code that somewhere it was waiting for a message that never come.
Although this part was working before I made some change in the order of loops and that was the blocking point.

Thanks too much for your help.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.