mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This patch has two desirable effects for the price of one. 1. An uncaught error thrown from main will now explode 2. Move us off of using runAsyncAndBlock The issue with runAsyncAndBlock is that it blocks the main thread outright. UI and the main actor need to run on the main thread or bad things happen, so blocking the main thread results in a bad day for them. Instead, we're using CFRunLoopRun to run the core-foundation run loop on the main thread, or, dispatch_main if CFRunLoopRun isn't available. The issue with just using dispatch_main is that it doesn't actually guarantee that it will run the tasks on the main thread either, just that it clears the main queue. We don't want to require everything that uses concurrency to have to include CoreFoundation either, but dispatch is already required, which supplies dispatch_main, which just empties out the main queue.
1010 B
1010 B