зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1355161 - provide a scriptable equivalent of NS_DispatchToMainThread, r=froydnj.
This commit is contained in:
Родитель
2fcb7c6663
Коммит
65ba8f32ee
|
@ -8,6 +8,7 @@
|
|||
|
||||
[ptr] native PRThread(PRThread);
|
||||
|
||||
interface nsIRunnable;
|
||||
interface nsIThread;
|
||||
|
||||
/**
|
||||
|
@ -79,4 +80,14 @@ interface nsIThreadManager : nsISupports
|
|||
* application process.
|
||||
*/
|
||||
readonly attribute boolean isMainThread;
|
||||
|
||||
/**
|
||||
* This queues a runnable to the main thread. It's a shortcut for JS callers
|
||||
* to be used instead of
|
||||
* .mainThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
|
||||
* or
|
||||
* .currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
|
||||
* C++ callers should instead use NS_DispatchToMainThread.
|
||||
*/
|
||||
void dispatchToMainThread(in nsIRunnable event);
|
||||
};
|
||||
|
|
|
@ -348,3 +348,17 @@ nsThreadManager::GetHighestNumberOfThreads()
|
|||
OffTheBooksMutexAutoLock lock(mLock);
|
||||
return mHighestNumberOfThreads;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsThreadManager::DispatchToMainThread(nsIRunnable *aEvent)
|
||||
{
|
||||
// Note: C++ callers should instead use NS_DispatchToMainThread.
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Keep this functioning during Shutdown
|
||||
if (NS_WARN_IF(!mMainThread)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
return mMainThread->DispatchFromScript(aEvent, 0);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче