Unlock This Episode
Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.
Introduction
OK, so we have now seen that with a little bit of runtime hackery we can get access to a “task enqueue global hook” that is completely public and even apart of Swift’s ABI, but just isn’t easily accessible. But, once we do have a handle on the hook, then we have the opportunity to be notified anytime an async unit of work is scheduled to be performed.
So, what can we do with this?
Brandon: Well, we can completely alter the manner in which jobs are enqueued. Right now we are just turning around and feeding the job back to the original enqueuer, which means the behavior is unchanged from the default. But we do have the ability to send those jobs to a different executor, such as a custom executor, or even serialize all the jobs onto the main executor.
Let’s take a look.
Subscribe to Point-Free
Access this episode, plus all past and future episodes when you become a subscriber.
Already a subscriber? Log in
References
Reliably testing code that adopts Swift Concurrency?
Brandon Williams & Stephen Celis • Friday May 13, 2022A Swift Forums post from yours truly about the difficulty of testing async code in Swift.
Concurrency Extras
Brandon Williams and Stephen Celis • Tuesday Jul 18, 2023An open source Swift package that provides powerful tools for making async code easier to test.
Announcing Concurrency Extras: Useful, testable Swift concurrency.
Brandon Williams and Stephen Celis • Tuesday Jul 18, 2023The announcement of our new Concurrency Extras library, which provides powerful tools for making async code easier to test.