Chapter 9 contains the following Note:
“Calling contains(_: ) on the cache keys directly, without fetching a local copy of the keys collection, produces memory corruption in release builds when there are concurrent updates. That’s why here you safely get a local copy of the keys and then you check for the existence of key.”
I’m a bit confused by this. My understanding is that memory corruption could occur here if one thread fetched the keys, while another edited the dictionary. However,
- cache is a property of ImageLoader
- ImageLoader is an actor
Which would imply (I think?) that access to cache is always serialized. What am I missing?