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.
Barrier example - Rust Tutorial
From the course: Rust: Asynchronous Programming with Tokio
Barrier example
- [Instructor] For our soda company example, we'll be using a barrier and notify to partition the soda can task into batches of 12. All right, let's start with the imports. Use standard library, sync arc. use tokio, sync barrier. Barrier wait result, and notify. Use tokio time sleep and duration. For the barrier function, we need to pass in the barrier notify, and then return a barrier wait result. So let's do that, and let's call this function barrier example. Barrier example, passing in a barrier, arc, barrier, notify, arc notify, and then returning a barrier result. So the main purpose of the barrier example is to have the barrier. So let's set that up. Let wait result equals to barrier. Wait dot await. And then let's print out what the task are going to be doing. Print line waiting, waiting at barrier. And then afterwards, print line pass through the barrier. Barrier wait results are special.…
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)
-
-