Tokio is the most widely used async runtime for Rust, powering everything from web servers to embedded systems. Mastering its primitives — spawn, join!, select!, and channels — is essential for writing correct and performant async Rust.
0 / 5 completed
1 / 5
You need two async tasks to run concurrently and collect both results. Which Tokio macro should you use?
join! drives all futures concurrently and waits for all to complete, returning a tuple of results. select! returns only the first to finish and cancels the rest.
2 / 5
What distinguishes an mpsc channel from a oneshot channel in Tokio?
mpsc (multi-producer, single-consumer) lets multiple senders push a stream of values to one receiver. A oneshot channel is a single-use rendezvous: it sends exactly one value and both ends are then dropped.
3 / 5
A Tokio task spawned with tokio::spawn panics. What happens to the spawning task?
Panics inside tokio::spawn are captured and returned as a JoinError inside the JoinHandle. The spawning task is unaffected unless it explicitly awaits and unwraps the handle.
4 / 5
Which statement best describes Tokio's select! macro?
select! races multiple async expressions and returns when the first one completes. The other futures are dropped (and therefore cancelled). This makes it useful for timeouts and cancellation patterns.
5 / 5
Why must types used across tokio::spawn boundaries be Send + 'static?
Tokio's default multi-thread runtime can steal tasks across OS threads. Send ensures captured data is safe to move between threads; 'static ensures captured references outlive the task, since the task lifetime is not tied to the spawning scope.