promotion
Powerful debugging in Xcode,
no code changes or 3rd party frameworks required.

TaskGroup as a workflow design tool

For my talk at iOS Conf SG 2022 I wanted to showcase some Swift concurrency use-cases that don’t fall into the common scenarios. Revisiting the slides some weeks later, I think it’d be fun to cover my TaskGroup example in more detail. In this post I’ll show how to use TaskGroup to design a complete (but fictional) user login-sequence. What is TaskGroup good for? Most examples floating around show using a TaskGroup to add a number of identical tasks to a group and execute them concurrently. …

Posted on

The issue with task groups or how I discovered a solved problem

This post is not my usual format but there is a moral at the end, so hang around if you have a little time to waste. The setup I’m working on a longer blog post about the process of optimizing some concurrency Swift code. At a point I used John Sundell’s CollectionConcurrencyKit to compare the performance of different approaches. After I had my numbers, I peaked into his code to double check what exactly am I measuring. …

Posted on

Announcing: “Modern Concurrency in Swift”

I’m incredibly happy to share that today the new raywenderlich.com book “Modern Concurrency in Swift”, that I’ve been working on, is available at swiftconcurrencybook.com! Together with editors Sandra Grauschopf, Felipe Laso-Marsetti, Richard Turton, and Shai Mishali, we’ve been working very hard to get a book out as soon as possible on the newly released in 2021 Swift Concurrency: The book is written in the classic raywenderlich.com style that mixes key pieces of theory with step-by-step instructions, guiding the readers through working on practical, real-life projects. …

Posted on

Actors, the cooperative pool and concurrency

After I started doing some benchmarking how different APIs perform, when used to build a simple counter, I got really interested to learn more about how the new Swift concurrency model behaves at runtime. So in this post I’ll use a couple of actors and make them do concurrent computations and check how the thread list and dispatch-queues look like in the debugger. The Test Setup I’ve prepared a super-duper simple SwiftUI app that does a bunch of floating-point multiplication and division. …

Posted on

Performance: Actor vs queue vs lock

I do a lot of performance and instrumenting work and I’ve found Peter Steinberger’s post here very useful when comparing lock alternatives. As I worked with async/await and actors more and more this summer, I thought it’d be nice to put together a short post offering some basic benchmarking of actors vs. the existing synchronization mechanisms. Disclaimer Benchmarking depends heavily on the system, temporary conditions, and more. As with any amateur benchmarks, take the numbers in this post with a grain of salt. …

Posted on

The difference between Thread.sleep() and Task.sleep()

With the work-in-progress backport of the new Swift concurrency model all the way to iOS13, async/await and friends are getting more and more relevant for all Swift developers. So here’s a quick and simple example that showcases some of the nice features of the new concurrency model without going into much detail. Thread.sleep() vs Task.sleep() Let’s just look at the old and new sleep APIs: Thread.sleep() is the old API that blocks a thread for the given amount of seconds — it doesn’t load the CPU, the core just idles. …

Posted on