Skip to main content

spawn_bound

Function spawn_bound 

Source
pub fn spawn_bound<F>(fut: F) -> JoinHandle<F::Output> 
where F: Future + Send + 'static, F::Output: Send + 'static,
Expand description

Spawn a task pinned to the CURRENT account.

Everything it does through db:: resolves to that account for as long as it runs, so an account switch mid-flight can no longer redirect its writes. Use this for any task that touches per-account state; a bare tokio::spawn leaves the task reading whoever is live at the moment it asks.