Function lunatic_runtime::spawn[][src]

pub fn spawn<F, K>(func: F) -> (JoinHandle<()>, NativeProcess) where
    K: Future<Output = Result<()>> + Send + 'static,
    F: FnOnce(NativeProcess, MessageMailbox) -> K, 
Expand description

Spawns a process from a closure.

Example:

let _proc = lunatic_runtime::spawn(|_this, mailbox| async move {
    // Wait on a message with the tag `27`.
    mailbox.pop(Some(&[27])).await;
    Ok(())
});