[Review] SF-0011: Concurrency-Safe Notifications

2 × 2 cents:

  • I think I fully agree with @FranzBusch: NotificationCenter should not create Tasks, and async notification handlers looks out of place since synchronous delivery of notifications has always been 1. a very important feature of NotificationCenter and 2. a use case that still exists, even out of the main actor).

  • I remember an important forum thread (Reliably testing code that adopts Swift Concurrency?) that was using async sequences built from NotificationCenter as an example of an api that was difficult to test (and generally to use) because the task that starts iterating notifications can easily miss the first ones. Call this a data race of a race condition, I don't quite care: this is a bug-prone api. I wish this problem was fully acknowledged, and very explicitly considered and addressed, if not solved, in this proposal.

8 Likes