зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1046109: Add |SocketIODeleteInstanceRunnable|, r=kyle
|SocketIODeleteInstanceRunnable| deletes a Socket I/O object on the main thread. This is required to serialize the close operation of Socket consumers.
This commit is contained in:
Родитель
83a32d0363
Коммит
f24375cd4f
|
@ -276,6 +276,27 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/* |SocketIODeleteInstanceRunnable| deletes an object on the main thread.
|
||||
*/
|
||||
template<class T>
|
||||
class SocketIODeleteInstanceRunnable MOZ_FINAL : public nsRunnable
|
||||
{
|
||||
public:
|
||||
SocketIODeleteInstanceRunnable(T* aInstance)
|
||||
: mInstance(aInstance)
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE
|
||||
{
|
||||
mInstance = nullptr; // delete instance
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsAutoPtr<T> mInstance;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,25 +182,6 @@ private:
|
|||
CancelableTask* mDelayedConnectTask;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class DeleteInstanceRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DeleteInstanceRunnable(T* aInstance)
|
||||
: mInstance(aInstance)
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
delete mInstance;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
T* mInstance;
|
||||
};
|
||||
|
||||
class UnixSocketImplTask : public CancelableTask
|
||||
{
|
||||
public:
|
||||
|
@ -328,7 +309,8 @@ public:
|
|||
// that no more tasks reference it.
|
||||
impl->ShutdownOnIOThread();
|
||||
|
||||
nsRefPtr<nsIRunnable> r(new DeleteInstanceRunnable<UnixSocketImpl>(impl));
|
||||
nsRefPtr<nsIRunnable> r =
|
||||
new SocketIODeleteInstanceRunnable<UnixSocketImpl>(impl);
|
||||
nsresult rv = NS_DispatchToMainThread(r);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче