mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1186745 part 2 - Move nsThreadSyncDispatch class to its own header file. r=froydnj
This commit is contained in:
parent
42f427fd1f
commit
8eae1acd07
@ -36,6 +36,7 @@
|
|||||||
#include "nsXPCOMPrivate.h"
|
#include "nsXPCOMPrivate.h"
|
||||||
#include "mozilla/ChaosMode.h"
|
#include "mozilla/ChaosMode.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
|
#include "nsThreadSyncDispatch.h"
|
||||||
#include "LeakRefPtr.h"
|
#include "LeakRefPtr.h"
|
||||||
|
|
||||||
#ifdef MOZ_CRASHREPORTER
|
#ifdef MOZ_CRASHREPORTER
|
||||||
@ -1172,20 +1173,6 @@ nsThread::SetScriptObserver(mozilla::CycleCollectedJSRuntime* aScriptObserver)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsThreadSyncDispatch::Run()
|
|
||||||
{
|
|
||||||
if (mSyncTask) {
|
|
||||||
mResult = mSyncTask->Run();
|
|
||||||
mSyncTask = nullptr;
|
|
||||||
// unblock the origin thread
|
|
||||||
mOrigin->Dispatch(this, NS_DISPATCH_NORMAL);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsThread::nsNestedEventTarget, nsIEventTarget)
|
NS_IMPL_ISUPPORTS(nsThread::nsNestedEventTarget, nsIEventTarget)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -207,36 +207,6 @@ protected:
|
|||||||
MainThreadFlag mIsMainThread;
|
MainThreadFlag mIsMainThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class nsThreadSyncDispatch : public nsRunnable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
nsThreadSyncDispatch(nsIThread* aOrigin, already_AddRefed<nsIRunnable>&& aTask)
|
|
||||||
: mOrigin(aOrigin)
|
|
||||||
, mSyncTask(aTask)
|
|
||||||
, mResult(NS_ERROR_NOT_INITIALIZED)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsPending()
|
|
||||||
{
|
|
||||||
return mSyncTask != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult Result()
|
|
||||||
{
|
|
||||||
return mResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
NS_DECL_NSIRUNNABLE
|
|
||||||
|
|
||||||
nsCOMPtr<nsIThread> mOrigin;
|
|
||||||
nsCOMPtr<nsIRunnable> mSyncTask;
|
|
||||||
nsresult mResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(XP_UNIX) && !defined(ANDROID) && !defined(DEBUG) && HAVE_UALARM \
|
#if defined(XP_UNIX) && !defined(ANDROID) && !defined(DEBUG) && HAVE_UALARM \
|
||||||
&& defined(_GNU_SOURCE)
|
&& defined(_GNU_SOURCE)
|
||||||
# define MOZ_CANARY
|
# define MOZ_CANARY
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "nsAutoPtr.h"
|
#include "nsAutoPtr.h"
|
||||||
#include "prinrval.h"
|
#include "prinrval.h"
|
||||||
#include "mozilla/Logging.h"
|
#include "mozilla/Logging.h"
|
||||||
|
#include "nsThreadSyncDispatch.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
|
||||||
|
49
xpcom/threads/nsThreadSyncDispatch.h
Normal file
49
xpcom/threads/nsThreadSyncDispatch.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* -*- 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/. */
|
||||||
|
|
||||||
|
#ifndef nsThreadSyncDispatch_h_
|
||||||
|
#define nsThreadSyncDispatch_h_
|
||||||
|
|
||||||
|
#include "nsThreadUtils.h"
|
||||||
|
|
||||||
|
class nsThreadSyncDispatch : public nsRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nsThreadSyncDispatch(nsIThread* aOrigin, already_AddRefed<nsIRunnable>&& aTask)
|
||||||
|
: mOrigin(aOrigin)
|
||||||
|
, mSyncTask(aTask)
|
||||||
|
, mResult(NS_ERROR_NOT_INITIALIZED)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsPending()
|
||||||
|
{
|
||||||
|
return mSyncTask != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult Result()
|
||||||
|
{
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
NS_IMETHOD Run() override
|
||||||
|
{
|
||||||
|
if (mSyncTask) {
|
||||||
|
mResult = mSyncTask->Run();
|
||||||
|
mSyncTask = nullptr;
|
||||||
|
// unblock the origin thread
|
||||||
|
mOrigin->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIThread> mOrigin;
|
||||||
|
nsCOMPtr<nsIRunnable> mSyncTask;
|
||||||
|
nsresult mResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // nsThreadSyncDispatch_h_
|
Loading…
Reference in New Issue
Block a user