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

TIMOB-13020 First pass attempt to unroll and keep propertyChanged in a single UI callback. #3959

Merged
merged 1 commit into from Mar 19, 2013

Conversation

WhichKatieDid
Copy link
Contributor

Test is in Jira.

@ayeung
Copy link
Contributor

ayeung commented Mar 16, 2013

Maybe I'm missing something here, but from my understanding you're trying to make it so we don't jump from the runtime thread to the main thread for each property in applyProperties()? If so, why don't we just move the current applyProperties() logic into a new method called doApplyProperties(), and just check if it's in the UI thread. If it is, call doApplyProperties() else, send it over to the UI thread and then call doApplyProperties().

@WhichKatieDid
Copy link
Contributor Author

The reason was that I was trying to minimally change behavior as possible. That is, if I were to jump to UI thread in a blocking manner, there'd be a performance hit. Were I to jump in a nonblocking manner, there'd be a race condition as doing foo.applyProperties({bar:5});foo.bar; (or perhaps a more complicated property) may allow for foo.bar to be read before the 5 is applied.

I wanted to cause as minimal behavior change (and risk of regression) as possible. I unraveled the old applyProperties and found there were three situations: One in the main thread, one in a background thread, and one where the modellistener was null, which mooted the difference. That's why it has three different codepaths, and only one that does the callout.

setProperty(name, value);
if (shouldFireChange(current, value)) {
modelListener.propertyChanged(name, current, value, this);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just call setAndFireProperty() instead of doing all this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setAndFireProperty has a lot of checks that we can aggregate, such as TiApplication.isUIThread() and checking on modelListener. Part of the optimization was to remove redundant, unnecessary checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@ayeung
Copy link
Contributor

ayeung commented Mar 18, 2013

Code reviewed, left comments.

@WhichKatieDid
Copy link
Contributor Author

Comments responded.

@ayeung
Copy link
Contributor

ayeung commented Mar 19, 2013

Code reviewed and functionally tested. Request Accepted.

ayeung pushed a commit that referenced this pull request Mar 19, 2013
TIMOB-13020 First pass attempt to unroll and keep propertyChanged in a single UI callback.
@ayeung ayeung merged commit beb39b6 into tidev:master Mar 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants