- check the cache and return the value if found
- with mutex locked
1. if the ID is currently in flight, get its condition variable
2. if ID is not in flight, check the cache again for the item
- if it was in the cache, return the item
- if not in the cache
- if there's room for another in-flight request 1. add a condition variable to the list of in-flight requests
- if the ID was already in flight, wait on the condition variable we got for it 1. when the condition variable signals, return the item from the cache
- if we own the new condition variable
1. make the request and store it in the cache
2. with mutex locked
- signal the condition variable 3. return the cached item
- if there was no room to add another in-flight request
1. wait on the queue-full resource
- start the loop over
Last active
February 10, 2016 17:41
-
-
Save RobinDaugherty/69ac444adccbcee13bab to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment