mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When building the Swift standard library, the compiler warns: ``` warning: capture of 'wordPtr' with non-sendable type 'UnsafeMutablePointer<Builtin.Word>' in a `@Sendable` closure ``` This diagnostic will become an error in the Swift 6 language mode, so it needs to be addressed. This PR factors the atomic operations used by the implementation of `Task.sleep()` into an `@unchecked Sendable` wrapper in order to convince the compiler that these operations are thread-safe. As an added benefit, the code is more readable when the atomic operatios are abstracted away. This refactor intentionally translates the existing implementation into a wrapper as faithfully as possible and does not attempt to improve on any other aspects of the implementation, such as the unsafe manual memory allocation and deallocation.
11 KiB
11 KiB