stanfordbdhg/threadlocal
This source file is part of the ThreadLocal open source project
Overview
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.
Installation
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.
License
This project is licensed under the MIT License. See Licenses for more information.
Contributors
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.
[Stanford Byers Center for Biodesign Logo] [Stanford Byers Center for Biodesign Logo]
Package Metadata
Repository: stanfordbdhg/threadlocal
Default branch: main
README: README.md