-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add thread safety to Clock #110
base: main
Are you sure you want to change the base?
Add thread safety to Clock #110
Conversation
2ed9bde
to
256fbb6
Compare
@keith @sberrevoets Any chance to get feedback on this? 🙏 |
256fbb6
to
577b925
Compare
Can you add some tests here that demonstrate (how) this works? CI doesn't really work here but as long as they pass locally that's probably alright for now. We don't need thread safety at Lyft, so we can't really support it in the sense that if this breaks we'd be able to fix it, but if there's some reasonable evidence this works as expected I don't really see a reason why we couldn't add it. As an aside, have you looked into using a more modern Swift concurrency approach to this? Using async/await, making Clock an actor, annotating it with |
577b925
to
225a326
Compare
I am not sure if it is possible to reliably test thread safety in unit tests (see this and this). Running the code in the application and checking the thread sanitizer is probably the best we can do. Calling the
That should be relatively easy but I didn't want to break the existing API. |
22cb9c9
to
2bf08af
Compare
Signed-off-by: Seweryn Plażuk <[email protected]>
2bf08af
to
73f806e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest changing to a modern API anyway, but realized it probably doesn't matter since a lot of the callsites use GCD so that wouldn't really solve the problem here. It's probably worth adding that in the meantime, but no need to hold up this PR for that.
I assume you've used this in prod for a while? No problems that came up?
@sberrevoets Hey, thanks for the approval and sorry for the slight delay in responding. Fix has been in production for over a week now and we haven't noticed any worrying symptoms. In any case, the linter failed on the code I haven't touched. How would you advise to proceed? Can this be merged regardless? |
@sberrevoets Could you please approve the PR checks? |
I just did but they'll likely fail because there is a problem with the tests and how they run on GitHub in general |
This PR appends thread safety to Clock
stableTime
property, using single unfair lock.Solves #85.