From the course: Rust: Asynchronous Programming with Tokio
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Notify example - Rust Tutorial
From the course: Rust: Asynchronous Programming with Tokio
Notify example
- [Instructor] We will use notify to assimilate buying things online, with an emphasis on the notification you receive when your package has been delivered. Let's start with the imports. Use standard library sync arc. Use tokio sync notify. Use tokio time, sleep and duration. We're going to create two functions. One function will handle everything on the company side when you order a package. Async function, let's call it order package. And the other function will handle everything on the person's side, like looking around the house and actually grabbing the package. So let's call that grab package. Both of these functions will take a reference to notify. Package delivered arc notify, and put that here as well. Package delivered, type arc notify. For the order package function, we're going to walk through the steps that the company has to take. So let's print some stuff out. We have to find the package in…
Contents
-
-
-
-
-
(Locked)
What are asynchronous primitives?2m 16s
-
(Locked)
What is a mutex?2m 6s
-
(Locked)
Mutex example5m 43s
-
(Locked)
What is a semaphore?1m 57s
-
(Locked)
Semaphore example6m 24s
-
(Locked)
What is notify?1m 39s
-
(Locked)
Notify example5m 45s
-
(Locked)
What is a barrier?1m 55s
-
(Locked)
Barrier example7m 12s
-
(Locked)
What is RwLock?2m 10s
-
(Locked)
RwLock example8m 11s
-
(Locked)
-
-