Module 32: Background Tasks
Check your understanding
A quick multiple-choice check before you move on. Answer every question, then submit to see how you did.
1.You write let mut interval = tokio::time::interval(Duration::from_secs(5)); loop { interval.tick().await; work(); }. When does work() first run?
2.A C# developer expects that dropping the JoinHandle returned by tokio::spawn will stop the background task. What actually happens in Rust?
3.In the theory's mpsc work-queue pattern, what does the background consumer do when the channel is currently empty but the sender is still alive?
4.How does tokio's default interval first-tick behavior contrast with C#'s PeriodicTimer.WaitForNextTickAsync()?
5.If a periodic task's work() sometimes takes longer than the interval period, what is tokio's default behavior for the tick that was missed?
Answer every question to submit.