MCPcopy Create free account
hub / github.com/3rfaan/courses / main

Function main

Rust/Asynchronous Programming/timer_future/src/main.rs:98–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96}
97
98fn main() {
99 let (executor, spawner) = new_executor_and_spawner();
100
101 // Spawn a task to print before and after waiting on a timer.
102 spawner.spawn(async {
103 println!("howdy!");
104 // Wait for our timer future to complete after two seconds
105 TimerFuture::new(Duration::new(2, 0)).await;
106 println!("done!");
107 });
108
109 // Drop the spawner so that our executor knows it is finished and won't
110 // receive more incoming tasks to run.
111 drop(spawner);
112
113 // Run the executor until the task queue is empty.
114 // This will print "howdy!", pause, and then print "done!".
115 executor.run();
116}

Callers

nothing calls this directly

Calls 3

new_executor_and_spawnerFunction · 0.85
spawnMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected