Skip to content

brianaltan/tutorial10-timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reflection

1.2 Understanding how it works.

fn main() {
    let (executor, spawner) = new_executor_and_spawner();

    spawner.spawn(async {
        println!("Brian's Komputer: howdy!");
        TimerFuture::new(Duration::new(2, 0)).await;
        println!("Brian's Komputer: done!");
    });

    println!("Brian's Komputer: hey hey");
    
    drop(spawner);
    executor.run();
}

Async tasks are not executed when they are created; instead, they are simply placed in a queue. The synchronous print statement "hey hey" runs immediately, after which the spawner is dropped. Then the executor.run() initiates the processing of the queued async tasks.

1.3 Experiment 1.3: Multiple Spawn and removing drop

With drop

Without drop

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages