Bug 1033358 - Make NS_IsMainThread use its own TLS so it's always correct, from early init to exit time - r=bsmedberg

This commit is contained in:
Benoit Jacob
2014-07-04 06:34:15 -04:00
parent f2b3eb970f
commit 74fee105cf
5 changed files with 28 additions and 44 deletions

View File

@@ -125,34 +125,7 @@ NS_GetMainThread(nsIThread** aResult)
#endif
}
#if defined(MOZILLA_INTERNAL_API) && defined(XP_WIN)
extern DWORD gTLSThreadIDIndex;
bool
NS_IsMainThread()
{
return TlsGetValue(gTLSThreadIDIndex) == (void*)mozilla::threads::Main;
}
#elif defined(MOZILLA_INTERNAL_API) && defined(NS_TLS)
#ifdef MOZ_ASAN
// Temporary workaround, see bug 895845
bool
NS_IsMainThread()
{
return gTLSThreadID == mozilla::threads::Main;
}
#else
// NS_IsMainThread() is defined inline in MainThreadUtils.h
#endif
#else
#ifdef MOZILLA_INTERNAL_API
bool
NS_IsMainThread()
{
bool result = false;
nsThreadManager::get()->nsThreadManager::GetIsMainThread(&result);
return bool(result);
}
#else
#ifndef MOZILLA_INTERNAL_API
bool
NS_IsMainThread()
{
@@ -165,7 +138,6 @@ NS_IsMainThread()
return bool(result);
}
#endif
#endif
NS_METHOD
NS_DispatchToCurrentThread(nsIRunnable* aEvent)