Locks – Mutex, Condvar, Barriers and RWLock

In this chapter, we're going to do a deep-dive on hopper, the grown-up version of Ring from Chapter 4, Sync and Send – the Foundation of Rust Concurrency. Hopper's approach to back-pressurethe weakness we identified in telemis to block when filled to capacity, as SyncSender does. Hopper's special trick is that it pages out to disk. The hopper user defines how many bytes of in-memory space hopper is allowed to consume, like SyncSender, except in terms of bytes rather than total elements of T. Furthermore, the user is able to configure the number of on-disk bytes that are consumed when hopper's in-memory capacity is filled and it has to page out to disk. The other properties of MSPC are held, in-order delivery, retention of data once stored, and so on.

Before we can dig through hopper, however, we need to introduce more of Rust's concurrency primitives. We'll work on some puzzles from The Little Book of Semaphores to explain them, which will get a touch hairy in some places on account of how Rust does not have a semaphore available.

By the close of this chapter, we will have:

  • Discussed the purpose and use of Mutex, Condvar, Barriers, and RWLock
  • Investigated a disk-backed specialization of the standard library's MPSC called hopper 
  • Seen how to apply QuickCheck, AFL, and comprehensive benchmarks in a production setting
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.173.238