Skip to main content

spawn_coroutine_with_context

Function spawn_coroutine_with_context 

Source
pub fn spawn_coroutine_with_context<T, C, F, Fut>(
    context: C,
    f: F,
) -> CommunicationTask<T>
where F: FnMut(&mut C, T) -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static, C: Send + 'static, T: Send + 'static,
Expand description

Spawns a new asynchronous task with provided context that accepts messages to the task. This function returns a handle that allows sending a message, or if there is no reference to the handle at all (in other words, all handles are dropped), the task would be aborted.

ยงNote

If state must be borrowed across awaits, use spawn_coroutine_with_receiver_and_context.