Make NS_IsMainThread faster on our major platforms. (Bug 521750) r=dbaron

This commit is contained in:
Benjamin Smedberg
2009-10-28 10:28:57 -07:00
parent cf6adad881
commit 1823ed419e
5 changed files with 57 additions and 11 deletions

View File

@@ -116,20 +116,29 @@ NS_GetMainThread(nsIThread **result)
#endif
}
NS_METHOD_(PRBool)
NS_IsMainThread()
#ifndef MOZILLA_INTERNAL_API
bool NS_IsMainThread()
{
PRBool result = PR_FALSE;
#ifdef MOZILLA_INTERNAL_API
nsThreadManager::get()->nsThreadManager::GetIsMainThread(&result);
#else
nsCOMPtr<nsIThreadManager> mgr =
do_GetService(NS_THREADMANAGER_CONTRACTID);
do_GetService(NS_THREADMANAGER_CONTRACTID);
if (mgr)
mgr->GetIsMainThread(&result);
#endif
return result;
return bool(result);
}
#elif !defined(NS_TLS)
bool NS_IsMainThread()
{
PRBool result = PR_FALSE;
nsThreadManager::get()->nsThreadManager::GetIsMainThread(&result);
return bool(result);
}
#elif !defined(MOZ_ENABLE_LIBXUL)
bool NS_IsMainThread()
{
return gTLSIsMainThread;
}
#endif
NS_METHOD
NS_DispatchToCurrentThread(nsIRunnable *event)