Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move RWLock to SpeziFoundation #45

Open
1 task done
Supereg opened this issue Jul 16, 2024 · 0 comments · May be fixed by #49
Open
1 task done

Move RWLock to SpeziFoundation #45

Supereg opened this issue Jul 16, 2024 · 0 comments · May be fixed by #49
Labels
enhancement New feature or request

Comments

@Supereg
Copy link
Member

Supereg commented Jul 16, 2024

Problem

With the migration to Strict Concurrency, PR #41 introduced RWLock and RecursiveRWLock primitives based on the POSIX threads library. This implementation might benefit the whole Spezi ecosystem.

Solution

Move those synchronization data structures to the SpeziFoundation package. These locks would join the AsyncSemaphore as reusable synchronization primitives.

Additional context

We might need to invest some design thinking on which interfaces to expose. We currently only expose async/wait safe withReadLock and withWriteLock methods. Do we want to expose plain lock/unlock methods that you need to balance yourself (see AsyncSemaphore how it is sometimes necessary). Those should then be annotated as not usable from async (see NSLock interface).

Code of Conduct

  • I agree to follow this project's Code of Conduct and Contributing Guidelines
@Supereg Supereg added the enhancement New feature or request label Jul 16, 2024
@Supereg Supereg mentioned this issue Jul 16, 2024
1 task
Supereg added a commit to StanfordSpezi/SpeziFoundation that referenced this issue Oct 17, 2024
# Introduce RWLock, ManagedAsynchronousAccess and DataDescriptor

## ♻️ Current situation & Problem
This PR adds the `RWLock`, `RecursiveRWLock` and
`ManagedAsynchronousAccess` infrastructure that was previously
introduced in SpeziBluetooth (see
StanfordSpezi/SpeziBluetooth#45 and
StanfordSpezi/SpeziBluetooth#47).
This changes require the Swift 6 toolchain. Therefore, we increase the
required swift tools version to 6.0.

This PR introduces the final changes for the SpeziFoundation 2.0 release
(assuming #16 is merged beforehand).

## ⚙️ Release Notes 
* Added `RWLock` and `RecursiveRWLock`
* Added `ManagedAsynchronousAccess`
* Only require `sending` closure with `withTimeout` instead of a
`@Sendable` one.
* Add new `DataDescriptor` type.


## 📚 Documentation
Updated the documentation catalog, adding a new "Concurrency" topics
section.


## ✅ Testing
Added unit test for the new components.


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
@Supereg Supereg linked a pull request Nov 4, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant