Rust concurrency patterns: condvars and locks
  1. Fetch 1 has checked the cache, found nothing, and started a networking request for the resource.
  2. Fetch 1 has not received headers from the network, hence hasn’t put a “pending resource” in the cache yet.
  3. Fetch 2 checks the cache for the same key as the one used by fetch 1, finds nothing, and goes the network as well.
  4. Fetch 1 receives headers, puts a pending resource in the cache. It’s too late, fetch 2 already went to the network.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gregory Terzian

Gregory Terzian


Software engineer living in Shanghai. I write in Javascript, Python, Rust, and English. Always for people to read.