Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Feb 5, 2025

This PR refactors the Locked type to be generic over the type of lock it uses, allowing us to adopt os_unfair_lock in most places, but also allowing us to use other lock types as needed (i.e. pthread_mutex_t in WaitFor.swift if libdispatch is unavailable.)

Under -O, locking and unlocking is fully inlined, while initialization (which is relatively rare) is partially, but not completely, inlined.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR refactors the `Locked` type to be generic over the type of lock it uses,
allowing us to adopt `os_unfair_lock` in most places, but also allowing us to
use other lock types as needed (i.e. `pthread_mutex_t` in WaitFor.swift if
libdispatch is unavailable.)

Under `-O`, locking and unlocking is fully inlined, while initialization (which
is relatively rare) is partially, but not completely, inlined.
@grynspan grynspan added enhancement New feature or request concurrency 🔀 Swift concurrency/sendability issues darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support performance 🏎️ Performance issues labels Feb 5, 2025
@grynspan grynspan added this to the Swift 6.x milestone Feb 5, 2025
@grynspan grynspan self-assigned this Feb 5, 2025
@grynspan
Copy link
Contributor Author

grynspan commented Feb 5, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Feb 5, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Feb 5, 2025

@swift-ci test

@grynspan grynspan requested a review from stmontgomery February 5, 2025 21:14
@grynspan
Copy link
Contributor Author

grynspan commented Feb 5, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Feb 5, 2025

@swift-ci test

@grynspan grynspan merged commit 63eb1d9 into main Feb 6, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/use-os-unfair-lock branch February 6, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency 🔀 Swift concurrency/sendability issues darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support enhancement New feature or request performance 🏎️ Performance issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants