-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
sync: sync watch local version with shared version #3731
Closed
Closed
Changes from all commits
Commits
Show all changes
2 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
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.
Having a method for doing something like this seems reasonable. I don't really like the name though.
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 admit that I have a hard time finding an ideal name as well.
Here are some proposals:
reconcile_version
|reconcile_local_version
|reconcile_version_counter
sync_version_counter
|sync_local_version
|synchronize_version
Maybe @pluyckx who reported the issue could help us on this?
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 agree it is hard to find a good function name. If I look at the names you propose, I see you add some information about the object's implementation details.
Maybe a name like
sync
orupdate
is better? In fact we are synchronizing the object's state. However, it is still not clear when/why you should call this function.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.
IMHO, this function is very specific and advanced, because it skips arbitrary amount of updates, and it is very easy to have a time-of-check-to-time-of-use bug (imagine that your task has been interrupted for an hour after the Receiver was creared, but before
sync_version
was called, highly likely applocation did not want to skip all this hour of updates, so it will behave incorrectly). That's why I'd give somewhat longer name, likeskip_all_pending_notifications
.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 think the name
skip_all_pending_notifications
is not perfect. As a user the wordnotifications
confuses me.skip_all_pending_changes
seems more appropriate. You wait for achange
, not for anotification
if you look at the API of aWatch
. Not sure if the wordall
is necessary in the name.The only question I have is, do we skip the changes or do we accept the last one? In the latter case then name
accept_last_change
is maybe a better option.For me skip is a synonym for ignore in this case. So when calling
borrow
after callingskip...
I expect the old value and not the latest sent to theWatch
.