зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1584568 - add a way to get the background event target; r=KrisWright
This function is needed for people whose needs don't map cleanly to `NS_DispatchToBackgroundThread`, usually because they're using the event target to do thread consistency checks. Once we have this function, we can start converting singleton threads/thread pools that want to use functionality like the above. Differential Revision: https://phabricator.services.mozilla.com/D47454 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b52f6bd330
Коммит
e284917829
|
@ -462,6 +462,16 @@ nsresult nsThreadManager::DispatchToBackgroundThread(nsIRunnable* aEvent,
|
|||
return backgroundTarget->Dispatch(aEvent, aDispatchFlags);
|
||||
}
|
||||
|
||||
nsresult nsThreadManager::GetBackgroundEventTarget(nsIEventTarget** aEventTarget) {
|
||||
if (!mInitialized) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventTarget> et(mBackgroundEventTarget);
|
||||
et.forget(aEventTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsThread* nsThreadManager::GetCurrentThread() {
|
||||
// read thread local storage
|
||||
void* data = PR_GetThreadPrivate(mCurThreadIndex);
|
||||
|
|
|
@ -56,6 +56,8 @@ class nsThreadManager : public nsIThreadManager {
|
|||
nsresult DispatchToBackgroundThread(nsIRunnable* aEvent,
|
||||
uint32_t aDispatchFlags);
|
||||
|
||||
nsresult GetBackgroundEventTarget(nsIEventTarget** aEventTarget);
|
||||
|
||||
// Returns the maximal number of threads that have been in existence
|
||||
// simultaneously during the execution of the thread manager.
|
||||
uint32_t GetHighestNumberOfThreads();
|
||||
|
|
|
@ -529,6 +529,10 @@ nsresult NS_DispatchToBackgroundThread(nsIRunnable* aEvent,
|
|||
return nsThreadManager::get().DispatchToBackgroundThread(aEvent, aDispatchFlags);
|
||||
}
|
||||
|
||||
nsresult NS_GetBackgroundEventTarget(nsIEventTarget** aEventTarget) {
|
||||
return nsThreadManager::get().GetBackgroundEventTarget(aEventTarget);
|
||||
}
|
||||
|
||||
// nsAutoLowPriorityIO
|
||||
nsAutoLowPriorityIO::nsAutoLowPriorityIO() {
|
||||
#if defined(XP_WIN)
|
||||
|
|
|
@ -1706,6 +1706,11 @@ extern nsresult NS_DispatchToBackgroundThread(already_AddRefed<nsIRunnable> aEve
|
|||
extern nsresult NS_DispatchToBackgroundThread(nsIRunnable* aEvent,
|
||||
uint32_t aDispatchFlags = NS_DISPATCH_NORMAL);
|
||||
|
||||
/**
|
||||
* Get the event target that NS_DispatchToBackgroundThread uses.
|
||||
*/
|
||||
extern nsresult NS_GetBackgroundEventTarget(nsIEventTarget** aEventTarget);
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче