Chapter 3. Building Our Own Async Queues

While we have explored some basic async syntax and solved a problem using high-level async concepts, it can be understandable that you are still not completely sure what tasks and futures really are and how they flow through the async runtime, despite being able to manipulate async crates and solve problems using async concepts. Describing futures and tasks can be difficult to do, and hard to understand. In this chapter, we will consolidate what we have learned about futures and tasks so far, and how they run through an async runtime by building our own async queues with minimal dependencies.

This async runtime will be customizable by choosing how many queues we have and how many consuming threads will be processing these queues. The implementation does not have to be uniform. For instance, we can have a low priority queue with two consuming threads, and a high priority queue having 5 consuming threads. We will then be able to choose which queue a future ...

Get Async Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.