mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1637500 - P3. Have GetCurrentSerialEventTarget return running XPCOMThreadWrapper. r=froydnj
This will allow to remove AbstractThread::Current() as GetCurrentSerialEventTarget TLS value will be set whenever a task dispatched on the XPCOMThreadWrapper is run. Differential Revision: https://phabricator.services.mozilla.com/D80355
This commit is contained in:
parent
87438519f0
commit
05a0f10af0
@ -96,4 +96,19 @@ TEST(TaskQueue, GetCurrentSerialEventTarget)
|
||||
tq1->AwaitShutdownAndIdle();
|
||||
}
|
||||
|
||||
TEST(AbstractThread, GetCurrentSerialEventTarget)
|
||||
{
|
||||
RefPtr<AbstractThread> mainThread = AbstractThread::GetCurrent();
|
||||
EXPECT_EQ(mainThread, AbstractThread::MainThread());
|
||||
Unused << mainThread->Dispatch(NS_NewRunnableFunction(
|
||||
"TestAbstractThread::TestCurrentSerialEventTarget::TestBody",
|
||||
[mainThread]() {
|
||||
nsCOMPtr<nsISerialEventTarget> thread = GetCurrentSerialEventTarget();
|
||||
EXPECT_EQ(thread, mainThread);
|
||||
}));
|
||||
|
||||
// Spin the event loop.
|
||||
NS_ProcessPendingEvents(nullptr);
|
||||
}
|
||||
|
||||
} // namespace TestTaskQueue
|
||||
|
@ -190,6 +190,7 @@ class XPCOMThreadWrapper final : public AbstractThread,
|
||||
NS_IMETHOD Run() override {
|
||||
MOZ_ASSERT(mThread == AbstractThread::GetCurrent());
|
||||
MOZ_ASSERT(mThread->IsCurrentThreadIn());
|
||||
SerialEventTargetGuard guard(mThread);
|
||||
return mRunnable->Run();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user