Function winmsg_executor::spawn

source ยท
pub fn spawn<F>(future: F) -> JoinHandle<F>
where F: Future + 'static, F::Output: 'static,
Expand description

Spawns a new future on the current thread.

This function may be used to spawn tasks when the message loop is not running. The provided future will start running once the message loop is entered with [MessageLoop::block_on()] or [MessageLoop::run()].

Examples found in repository?
examples/basic.rs (lines 22-27)
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
fn main() {
    println!("hello");
    block_on(async {
        let task = spawn(async {
            println!("async hello 1");
            poll_n_times(3).await;
            println!("async bye 1");
            "async 1 result"
        });

        println!("async hello 2");
        poll_n_times(2).await;
        println!("async bye 2");

        println!("{}", task.await);
    })
    .unwrap();
    println!("bye");
}