Thank you for your help.
Yes I was referring to that code that was posted to https://developer.apple.com/forums/thread/682032 (which was taken from the code section from the video of the "Developer" app where I was seeing it)
You say "There's no suspension points between reading the current state and writing something based on that state."
But:
Reading state: if let cached = cache[url] { … }
Suspension Point
let handle = async { try await downloadImage(from: url) }
Writing state: cache[url] = .inProgress(handle)
Suspension Point: let image = try await handle.get()
Writing state: Either cache[url] = .ready(image) or cache[url] = nil
What if task 2 enters while task 1 is at the first suspension point, and therefore reads the cache still as nil?
Is this some wrong thinking on my part? (Sorry)
Does the task handle not count as suspension point?
Topic:
Programming Languages
SubTopic:
Swift
Tags: