Modern Concurrency: Beyond the Basics

Oct 20 2022 · Swift 5.5, iOS 15, Xcode 13.4

Part 2: Concurrent Code

19. Challenge: Using a GlobalActor

Episode complete

Play next episode

About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 18. Using a GlobalActor Next episode: 20. Conclusion

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

In this challenge, you'll finish the debugging toolbar by connecting the second counter to display on disk cache hits and making the last toolbar button clear the disk cache. You should do something similar to what you did in image loader for the in-memory counter. In ImageDatabase, add an AsyncStream for the counter. Set up the stream in setup, manually complete it in a D init, and increment the counter when you have an actual disk cache hit. Update the toolbar view to iterate over the stream and make the last toolbar button clear the disk cache. Good luck. (gentle music) Welcome back. Hopefully you had success with this task. Here's how I did it. It's similar to what you did in image loader. In ImageDatabase, I added an AsyncStream for the counter. I set up the stream in the actor setup and manually completed the stream in a D initializer. I incremented the counter in image below the print in disk cache statement. At the end of clear, I reset the counter to zero and printed a message. Then in BottomToolbar below the other task, I added a task to iterate over the stream. Finally, I made the first toolbar button clear the disk cache. Now the disk counter works. When I clear both the disk and memory caches, the app fetches the images from the server. Congratulate yourself on a super useful debugging tool.