-
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
Replace pthread specifics with C11 thread-local variables #811
Conversation
pthread_setspecific(key, NULL); | ||
ASDisplayNodeCAssertNotNil(tls_context, @"Attempt to pop context when there wasn't a context!"); | ||
CFRelease((__bridge CFTypeRef)tls_context); | ||
tls_context = nil; |
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.
Used CFRelease directly here, since we don't actually want to bridge the value into ARC (no need to return id
, void
is fine.).
The danger warning is a false-positive. That file was created under Pinterest, so the current header correctly shows |
Generated by 🚫 Danger |
@Adlai-Holler I haven't made any changes to the dangerfile except to add an include so that it can read remote files again after the ruby upgrade 😬 |
…up#811) * Replace pthread specifics with C11 thread-local variables for speed and safety * Increment changelog
C11 thread-local variables are faster and safer than pthread_specifics. Let's use them!
Unfortunately, the pretty alias
thread_local
is defined inthreads.h
, an optional part of C11 that Clang doesn't support yet. But the actual_Thread_local
storage classifier works just fine. It calls intotlv_get_addr
provided bydyld
, and it's a lot faster thanpthread_getspecific
.Docs: http://en.cppreference.com/w/c/language/storage_duration
Here's the latest source available:
https://opensource.apple.com/source/dyld/dyld-519.2.2/src/threadLocalHelpers.s.auto.html
So 32-bit ARM this is built on pthread_getspecific. 64-bit ARM uses some crazy assembly that I don't understand.