-
Notifications
You must be signed in to change notification settings - Fork 163
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
Clock API improvements #580
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you clarify why the function isn't (same for the others)?
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 unsure about this actually, as I have not found an explicit statement of what we mean by thread-safe here. I meant it in the strictest sense i.e. concurrent access to the same object (which is an argument purely because of a language limitation) is safe. If by thread-safe we mean safe concurrent access for different objects or with no regard for objects (i.e. no shared global state), then all these functions here are, including those that add and remove callbacks.
I wonder if
Yes
andNo
for values are enough. Maybe a thirdConditional
value would help us in being a bit more precise.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.
Maybe @wjwwood can clarify how the
Thread-Safe
flag is used throughout the existing API.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 don't really think we need a third state for Thread-Safe. This one clearly isn't thread-safe; if you pass the same object into this method from two threads at the same time, that will leave the
clock
object in an undefined state. So it looks to me like "Thread-Safe: No" is appropriate here. The same goes for all of the APIs below.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 thought the same, but it's also true that there're varying degrees of thread (un)safety. You can manage different clocks in different threads without issues. Functions that access global state don't even allow that.
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.
And I think that kind of differentiated information would be very valuable for the user.
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.
@wjwwood bump
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.
Sorry, I thought I replied to this, but maybe I was dreaming, I was talking about it with the Apex folks recently too.
The idea is that you can call it from multiple threads concurrently, but also generally that it isn't affected by other functions being called concurrently. If there's any threading considerations like "can be called concurrently but not on the same object" or "can be called concurrently but not concurrently with fini on the same object, etc...".
Basically, I consider the footnote to be more important than the Yes or No. If you say "Yes" without a note, that would mean to me that the function is most likely pure functional and has no global, or input/output, side effects. If it accesses global state or modifies an object passed by non-const pointer, then you should consider having a No or Yes with a note.
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.
Alright, so it could be either so long as there's a note. I'll add one.
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.
There, see ca78af8. It's a bit verbose but it is accurate.