From the course: Build with AI: Developing a Discord Bot Conversationally

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Tokio runtime for async programming

Tokio runtime for async programming

- [Instructor] This is Rust async runtime that runs inside of Tokio and it powers the universal bot. It runs millions of concurrent tasks on just a few threads. You can think of it like a restaurant kitchen, maybe you have a few chefs, so these are the threads, and they have many orders, and these are the tasks that are running simultaneously, like cooking in a pot or chopping up some vegetables. And if you look at how the orchestration work inside of each of the current operations, we have a specific element in a box. First up, we have the Tokio runtime. This is the top blue box. This is the event loop. And this is a single-threaded coordinator for polling futures. We also have a scheduler, and this is gonna distribute the task across those worker threads. And then the I/O driver will manage the async network and file operations without blocking. So, that's really the core of the system. Now, in terms of the workers in…

Contents