Thread-local variables for Swift.
Use the ThreadLocal() macro to define a thread-local static variable:
extension SomeType {
@ThreadLocal
private static var counter: Int = 0
}Each thread will have its own version of the variable. On each thread, the variable is initially initialized to its default value (0 in the example above). When the thread is destroyed, the variable's lifetime is ended.
You can use non-trivial types with thread-local variables, and can provide a custom deallocator if needed (see ThreadLocal(deallocator:)).
See the documentation for more info.
The project can be added to your Xcode project or Swift Package using the Swift Package Manager.
Xcode: For an Xcode project, follow the instructions on adding package dependencies to your app.
Swift Package: You can follow the Swift Package Manager documentation about defining dependencies to add this project as a dependency to your Swift Package.
This project is licensed under the MIT License. See Licenses for more information.
This project is developed as part of the Stanford Mussallem Center for Biodesign at Stanford University. See CONTRIBUTORS.md for a full list of all ThreadLocal contributors.

