mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1186745 part 3 - Make nsThreadSyncDispatch leak the sync task by default when Run() is not called. r=froydnj
This commit is contained in:
parent
e6088a6eb9
commit
ad0c24a0c5
@ -8,20 +8,21 @@
|
||||
#define nsThreadSyncDispatch_h_
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
#include "LeakRefPtr.h"
|
||||
|
||||
class nsThreadSyncDispatch : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsThreadSyncDispatch(nsIThread* aOrigin, already_AddRefed<nsIRunnable>&& aTask)
|
||||
: mOrigin(aOrigin)
|
||||
, mSyncTask(aTask)
|
||||
, mSyncTask(mozilla::Move(aTask))
|
||||
, mResult(NS_ERROR_NOT_INITIALIZED)
|
||||
{
|
||||
}
|
||||
|
||||
bool IsPending()
|
||||
{
|
||||
return mSyncTask != nullptr;
|
||||
return !!mSyncTask;
|
||||
}
|
||||
|
||||
nsresult Result()
|
||||
@ -32,9 +33,8 @@ public:
|
||||
private:
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
if (mSyncTask) {
|
||||
mResult = mSyncTask->Run();
|
||||
mSyncTask = nullptr;
|
||||
if (nsCOMPtr<nsIRunnable> task = mSyncTask.take()) {
|
||||
mResult = task->Run();
|
||||
// unblock the origin thread
|
||||
mOrigin->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
@ -42,7 +42,9 @@ private:
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIThread> mOrigin;
|
||||
nsCOMPtr<nsIRunnable> mSyncTask;
|
||||
// The task is leaked by default when Run() is not called, because
|
||||
// otherwise we may release it in an incorrect thread.
|
||||
mozilla::LeakRefPtr<nsIRunnable> mSyncTask;
|
||||
nsresult mResult;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user