Bug 1300118 P3 Fix TaskQueue sCurrentThread TLS handling for nsIEventTarget targets. r=jwwang

This commit is contained in:
Ben Kelly 2016-09-12 11:21:01 -07:00
Родитель 64919e3546
Коммит 6ef08d4672
3 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -70,7 +70,6 @@ public:
PRThread* thread = nullptr;
mTarget->GetPRThread(&thread);
bool in = PR_GetCurrentThread() == thread;
MOZ_ASSERT(in == (GetCurrent() == this));
return in;
}

Просмотреть файл

@ -191,7 +191,6 @@ bool
TaskQueue::IsCurrentThreadIn()
{
bool in = NS_GetCurrentThread() == mRunningThread;
MOZ_ASSERT(in == (GetCurrent() == this));
return in;
}

Просмотреть файл

@ -148,13 +148,14 @@ protected:
public:
explicit AutoTaskGuard(TaskQueue* aQueue)
: AutoTaskDispatcher(/* aIsTailDispatcher = */ true), mQueue(aQueue)
, mLastCurrentThread(nullptr)
{
// NB: We don't hold the lock to aQueue here. Don't do anything that
// might require it.
MOZ_ASSERT(!mQueue->mTailDispatcher);
mQueue->mTailDispatcher = this;
MOZ_ASSERT(sCurrentThreadTLS.get() == nullptr);
mLastCurrentThread = sCurrentThreadTLS.get();
sCurrentThreadTLS.set(aQueue);
MOZ_ASSERT(mQueue->mRunningThread == nullptr);
@ -168,12 +169,13 @@ protected:
MOZ_ASSERT(mQueue->mRunningThread == NS_GetCurrentThread());
mQueue->mRunningThread = nullptr;
sCurrentThreadTLS.set(nullptr);
sCurrentThreadTLS.set(mLastCurrentThread);
mQueue->mTailDispatcher = nullptr;
}
private:
TaskQueue* mQueue;
AbstractThread* mLastCurrentThread;
};
TaskDispatcher* mTailDispatcher;