mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-08 00:07:30 +09:00
[XPCOM] xpcom Threadpool cleanup
Make sure thread locks are in place to guard accesses.
This commit is contained in:
parent
260cc45e51
commit
8751960d9a
1 changed files with 13 additions and 8 deletions
|
|
@ -155,8 +155,6 @@ nsThreadPool::Run()
|
||||||
{
|
{
|
||||||
mThreadNaming.SetThreadPoolName(mName);
|
mThreadNaming.SetThreadPoolName(mName);
|
||||||
|
|
||||||
LOG(("THRD-P(%p) enter %s\n", this, mName.BeginReading()));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIThread> current;
|
nsCOMPtr<nsIThread> current;
|
||||||
nsThreadManager::get().GetCurrentThread(getter_AddRefs(current));
|
nsThreadManager::get().GetCurrentThread(getter_AddRefs(current));
|
||||||
|
|
||||||
|
|
@ -169,6 +167,7 @@ nsThreadPool::Run()
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(mMutex);
|
MutexAutoLock lock(mMutex);
|
||||||
listener = mListener;
|
listener = mListener;
|
||||||
|
LOG(("THRD-P(%p) enter %s\n", this, mName.BeginReading()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listener) {
|
if (listener) {
|
||||||
|
|
@ -223,7 +222,12 @@ nsThreadPool::Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event) {
|
if (event) {
|
||||||
LOG(("THRD-P(%p) %s running [%p]\n", this, mName.BeginReading(), event.get()));
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
MutexAutoLock lock(mMutex);
|
||||||
|
LOG(("THRD-P(%p) %s running [%p]\n", this, mName.BeginReading(), event.get()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
event->Run();
|
event->Run();
|
||||||
}
|
}
|
||||||
} while (!exitThread);
|
} while (!exitThread);
|
||||||
|
|
@ -335,6 +339,7 @@ nsThreadPool::Shutdown()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThreadPool::GetThreadLimit(uint32_t* aValue)
|
nsThreadPool::GetThreadLimit(uint32_t* aValue)
|
||||||
{
|
{
|
||||||
|
MutexAutoLock lock(mMutex);
|
||||||
*aValue = mThreadLimit;
|
*aValue = mThreadLimit;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -358,6 +363,7 @@ nsThreadPool::SetThreadLimit(uint32_t aValue)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThreadPool::GetIdleThreadLimit(uint32_t* aValue)
|
nsThreadPool::GetIdleThreadLimit(uint32_t* aValue)
|
||||||
{
|
{
|
||||||
|
MutexAutoLock lock(mMutex);
|
||||||
*aValue = mIdleThreadLimit;
|
*aValue = mIdleThreadLimit;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -382,6 +388,7 @@ nsThreadPool::SetIdleThreadLimit(uint32_t aValue)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThreadPool::GetIdleThreadTimeout(uint32_t* aValue)
|
nsThreadPool::GetIdleThreadTimeout(uint32_t* aValue)
|
||||||
{
|
{
|
||||||
|
MutexAutoLock lock(mMutex);
|
||||||
*aValue = mIdleThreadTimeout;
|
*aValue = mIdleThreadTimeout;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -438,11 +445,9 @@ nsThreadPool::SetListener(nsIThreadPoolListener* aListener)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThreadPool::SetName(const nsACString& aName)
|
nsThreadPool::SetName(const nsACString& aName)
|
||||||
{
|
{
|
||||||
{
|
MutexAutoLock lock(mMutex);
|
||||||
MutexAutoLock lock(mMutex);
|
if (mThreads.Count()) {
|
||||||
if (mThreads.Count()) {
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mName = aName;
|
mName = aName;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue