mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Motivation: The SAL (Syscall Abstraction Layer) virtualises pretty much all system resources that NIO uses, except time and threads. That means that unless explicitly made sure, the EL thread and the test thread run at their own pace. The synchronisation point is whenever the EL thread makes a (virtualised) syscall which the test thread then sees (and asserts). The problem in #1748 was that we were assuming that the EL thread would park itself very fast. So when the test driver thread came along to execute something on the EL, it just assumed that the EL has already parked (ie. waited for a wakeup). Seemingly that works most of the time but not always. Modifications: - Always actually wait for the EL to park itself. - Delete duplicated code in `salWait` to use `runSAL` - fixes #1748 Result: Fewer races.