Files
swift-mirror/stdlib/public/Concurrency/TaskSleep.swift
Allan Shortlidge 851b47fbcd Concurrency: Factor atomic operations in Task.sleep() into a Sendable wrapper.
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.
2024-03-04 09:32:28 -08:00

11 KiB