mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-06-08 17:39:19 +00:00
42bb7c8c2c
In order to make sure that the MDSM properly dispatches everything via tail dispatch, we want verification that is more robust than simple inspection.
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "AbstractThread.h"
|
|
|
|
#include "MediaTaskQueue.h"
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
namespace mozilla {
|
|
|
|
StaticRefPtr<AbstractThread> sMainThread;
|
|
|
|
template<>
|
|
nsresult
|
|
AbstractThreadImpl<nsIThread>::Dispatch(already_AddRefed<nsIRunnable> aRunnable)
|
|
{
|
|
MediaTaskQueue::AssertInTailDispatchIfNeeded();
|
|
nsCOMPtr<nsIRunnable> r = aRunnable;
|
|
return mTarget->Dispatch(r, NS_DISPATCH_NORMAL);
|
|
}
|
|
|
|
template<>
|
|
bool
|
|
AbstractThreadImpl<nsIThread>::IsCurrentThreadIn()
|
|
{
|
|
bool in = NS_GetCurrentThread() == mTarget;
|
|
MOZ_ASSERT_IF(in, MediaTaskQueue::GetCurrentQueue() == nullptr);
|
|
return in;
|
|
}
|
|
|
|
AbstractThread*
|
|
AbstractThread::MainThread()
|
|
{
|
|
MOZ_ASSERT(sMainThread);
|
|
return sMainThread;
|
|
}
|
|
|
|
void
|
|
AbstractThread::InitStatics()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
MOZ_ASSERT(!sMainThread);
|
|
nsCOMPtr<nsIThread> mainThread;
|
|
NS_GetMainThread(getter_AddRefs(mainThread));
|
|
MOZ_DIAGNOSTIC_ASSERT(mainThread);
|
|
sMainThread = AbstractThread::Create(mainThread.get());
|
|
ClearOnShutdown(&sMainThread);
|
|
}
|
|
|
|
} // namespace mozilla
|