void Poll::setForThread(const Poll& poller) { Poll* old = getForThread(); // also has side-effect of initializing TLS if(old == &poller){ return; } pthread_setspecific(gTLSKey, &poller); }
void Looper::setForThread(const sp<Looper>& looper) { sp<Looper> old = getForThread(); // also has side-effect of initializing TLS if (looper != NULL) { looper->incStrong((void*)threadDestructor); } pthread_setspecific(gTLSKey, looper.get()); if (old != NULL) { old->decStrong((void*)threadDestructor); } }