Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Rust High Performance

You're reading from   Rust High Performance Learn to skyrocket the performance of your Rust applications

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher Packt
ISBN-13 9781788399487
Length 272 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
 Eguia Moraza Eguia Moraza
Author Profile Icon Eguia Moraza
Eguia Moraza
Arrow right icon
View More author details
Toc

Chapter 11. Asynchronous Programming

Until now, the only way we have seen to achieve concurrency in Rust is to create multiple threads, one way or another, to share the work. Nevertheless, those threads sometimes need to stop and look for something, such as a file or a network response. In those cases, the whole thread will be blocked and it will need to wait for the response.

This means that if we want to achieve a low latency for things such as an HTTP server, one way to do it is by spawning one thread per request, so that each request can be served as quickly as possible even if others block.

As we have seen, spawning hundreds of threads is not scalable, since each thread will have its own memory and will consume resources even if it's blocked. In this chapter, you will learn a new way of doing things by using asynchronous programming.

In this chapter, you will learn about the following:

  • Asynchronous primitives with mio
  • Using futures
  • The new async/await syntax and generators
  • Asynchronous I/O...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images