-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Upgrade ASLayoutElementContext to an Object #trivial #344
Conversation
Note: changed the names to push/pop because the semantics around what operations are allowed weren't totally clear once I moved to an object. Also, of course it would be cleaner to have a separate file and maybe a custom initializer, or even a class-method interface to this stuff, but I just wanted to get the basic approach up. |
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.
Nits aside, LGTM!
I agree that we should move to an object if it gives us more flexibility and even needed for other improvements. The number of context objects created shouldn't be big enough to cause noticeable overheads.
Source/Layout/ASLayoutElement.mm
Outdated
|
||
pthread_key_t ASLayoutElementContextKey; | ||
|
||
static void ASLayoutElementDestructor(void *p) { | ||
if (p != NULL) { | ||
ASDisplayNodeCFailAssert(@"Thread exited without clearing layout element context!"); |
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.
Nit: Indentation looks off.
Source/Layout/ASLayoutElement.mm
Outdated
// pthread_key_create must be called before the key can be used. This function does that. | ||
void ASLayoutElementContextEnsureKey() | ||
{ | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
pthread_key_create(&ASLayoutElementContextKey, free); | ||
// NOTE: NULL destructorm means that if a thread |
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.
What's up?
Hey Huy, thanks for the review |
* Upgrade ASLayoutElementContext to an object * Address feedback from Huy
This gives us a ton more flexibility for the future.
I'm on vacation so this was a little bit thrown-together, but I'm excited about it! Please give it a thorough review.
The GitHub diff got a little confused, so some lines that didn't change at all appear to have changed, like: