get_current_runtime

Function get_current_runtime 

Source
pub async fn get_current_runtime<'a>() -> RuntimeWrapper<'a>
Expand description

This gets the currently running runtime. PANICS IF IT IS CALLED FROM OUTSIDE THE RUNTIME.

Examples found in repository?
examples/tcp.rs (line 22)
19async fn go(addr: (&str, u16)) {
20    let mut listener = TcpListener::bind(addr).unwrap();
21    loop {
22        get_current_runtime()
23            .await
24            .push(handle(accept(&mut listener).await.unwrap()));
25    }
26}
More examples
Hide additional examples
examples/recursion.rs (line 13)
12async fn print_something_after_ms(ms: u64) {
13    get_current_runtime()
14        .await
15        .sleep(Duration::from_millis(ms))
16        .await;
17    println!("something after {ms}ms! :D");
18    get_current_runtime()
19        .await
20        .push(print_something_after_ms(ms + 1));
21}