Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

4pull tree cleanup #12

Merged
merged 3 commits into from
Jan 23, 2014
Merged

4pull tree cleanup #12

merged 3 commits into from
Jan 23, 2014

Conversation

stewartoallen
Copy link
Contributor

No description provided.

Stewart Allen added 3 commits January 23, 2014 10:44
@tea-dragon
Copy link
Contributor

For the deferred ops optimization, it would be even better if we could reliably skip the entire try/lock block by performing the if condition earlier. This would be nice for both performance and clarity -- I am not a big fan of our frequent use of null values as sentinals. Clearly it is possible to check "child != null" but in practice child is never null -- updateParentData is only ever called right after a method call on the same child object passed in.

The data variable is a little trickier because it is lazily instantiated for new nodes (or nodes that previously had no data attachments in their config and were later given one and then processed again, but that is an extreme corner case). The typical tree traversal has parent nodes that were previously processed by the same thread as child nodes - in such a case it is guaranteed that data will correctly appear as non-null or null. It wouldn't be safe to modify or examine, but it would be enough to tell whether the node had to be locked to process updates for it. It is less obvious whether this traversal is, or could easily be converted to, an actual invariant. TreeStates are pretty flexible with their processing stack. Given that most nodes don't actually have data and almost every case in terms of processing frequency allows the check to be safely made, it would be nice if someone could finish the theorem so to speak, but that's an issue for another day maybe.

tea-dragon added a commit that referenced this pull request Jan 23, 2014
@tea-dragon tea-dragon merged commit 2402394 into addthis:master Jan 23, 2014
@stewartoallen stewartoallen deleted the 4pull-tree-cleanup branch February 6, 2014 21:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants