optimize nsThreadManager::IsMainThread

git-svn-id: svn://10.0.0.236/branches/THREADS_20060213_BRANCH@190510 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%meer.net
2006-02-18 03:56:53 +00:00
parent c84d17db36
commit 1af1b725f9
3 changed files with 6 additions and 6 deletions

View File

@@ -66,6 +66,7 @@ public:
private:
friend class nsThreadShutdownTask;
friend class nsThreadManager;
~nsThread();

View File

@@ -86,6 +86,7 @@ nsThreadManager::Init()
return NS_ERROR_OUT_OF_MEMORY;
mainThread->InitCurrentThread();
mMainPRThread = mainThread->mThread;
return NS_OK;
}
@@ -210,9 +211,6 @@ nsThreadManager::SetCurrentThread(nsIThread *thread, nsIThread **result)
NS_IMETHODIMP
nsThreadManager::IsMainThread(PRBool *result)
{
nsCOMPtr<nsIThread> mainThread;
GetMainThread(getter_AddRefs(mainThread));
NS_ENSURE_STATE(mainThread);
return mainThread->IsOnCurrentThread(result);
*result = (PR_GetCurrentThread() == mMainPRThread);
return NS_OK;
}

View File

@@ -62,13 +62,14 @@ public:
void Shutdown();
private:
nsThreadManager() : mCurThreadIndex(0) {}
nsThreadManager() : mCurThreadIndex(0), mMainPRThread(nsnull) {}
~nsThreadManager() {}
static nsThreadManager sInstance;
nsInterfaceHashtableMT<nsCStringHashKey, nsIThread> mThreads;
PRUintn mCurThreadIndex; // thread-local-storage index
PRThread *mMainPRThread;
};
#define NS_THREADMANAGER_CLASSNAME "nsThreadManager"