зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1190495 - Separate FlushableTaskQueue into its own file. r=cpearce
This thing is garbage, and I don't want to hoist it into XPCOM.
This commit is contained in:
Родитель
29e4811fef
Коммит
bdf89c24e4
|
@ -0,0 +1,51 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#include "FlushableTaskQueue.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
void
|
||||
FlushableTaskQueue::Flush()
|
||||
{
|
||||
MonitorAutoLock mon(mQueueMonitor);
|
||||
AutoSetFlushing autoFlush(this);
|
||||
FlushLocked();
|
||||
AwaitIdleLocked();
|
||||
}
|
||||
|
||||
nsresult
|
||||
FlushableTaskQueue::FlushAndDispatch(already_AddRefed<nsIRunnable> aRunnable)
|
||||
{
|
||||
MonitorAutoLock mon(mQueueMonitor);
|
||||
AutoSetFlushing autoFlush(this);
|
||||
FlushLocked();
|
||||
nsCOMPtr<nsIRunnable> r = dont_AddRef(aRunnable.take());
|
||||
nsresult rv = DispatchLocked(r.forget(), IgnoreFlushing, AssertDispatchSuccess);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
AwaitIdleLocked();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
FlushableTaskQueue::FlushLocked()
|
||||
{
|
||||
// Make sure there are no tasks for this queue waiting in the caller's tail
|
||||
// dispatcher.
|
||||
MOZ_ASSERT_IF(AbstractThread::GetCurrent(),
|
||||
!AbstractThread::GetCurrent()->TailDispatcher().HasTasksFor(this));
|
||||
|
||||
mQueueMonitor.AssertCurrentThreadOwns();
|
||||
MOZ_ASSERT(mIsFlushing);
|
||||
|
||||
// Clear the tasks. If this strikes you as awful, stop using a
|
||||
// FlushableTaskQueue.
|
||||
while (!mTasks.empty()) {
|
||||
mTasks.pop();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- 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 FlushableTaskQueue_h_
|
||||
#define FlushableTaskQueue_h_
|
||||
|
||||
#include "mozilla/TaskQueue.h"
|
||||
|
||||
//
|
||||
// WARNING: THIS CLASS IS DEPRECATED AND GOING AWAY. DO NOT USE IT!
|
||||
//
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class FlushableTaskQueue : public TaskQueue
|
||||
{
|
||||
public:
|
||||
explicit FlushableTaskQueue(already_AddRefed<SharedThreadPool> aPool) : TaskQueue(Move(aPool)) {}
|
||||
nsresult FlushAndDispatch(already_AddRefed<nsIRunnable> aRunnable);
|
||||
void Flush();
|
||||
|
||||
bool IsDispatchReliable() override { return false; }
|
||||
|
||||
private:
|
||||
|
||||
class MOZ_STACK_CLASS AutoSetFlushing
|
||||
{
|
||||
public:
|
||||
explicit AutoSetFlushing(FlushableTaskQueue* aTaskQueue) : mTaskQueue(aTaskQueue)
|
||||
{
|
||||
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
|
||||
mTaskQueue->mIsFlushing = true;
|
||||
}
|
||||
~AutoSetFlushing()
|
||||
{
|
||||
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
|
||||
mTaskQueue->mIsFlushing = false;
|
||||
}
|
||||
|
||||
private:
|
||||
FlushableTaskQueue* mTaskQueue;
|
||||
};
|
||||
|
||||
void FlushLocked();
|
||||
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // FlushableTaskQueue_h_
|
|
@ -174,46 +174,6 @@ TaskQueue::BeginShutdown()
|
|||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
FlushableTaskQueue::Flush()
|
||||
{
|
||||
MonitorAutoLock mon(mQueueMonitor);
|
||||
AutoSetFlushing autoFlush(this);
|
||||
FlushLocked();
|
||||
AwaitIdleLocked();
|
||||
}
|
||||
|
||||
nsresult
|
||||
FlushableTaskQueue::FlushAndDispatch(already_AddRefed<nsIRunnable> aRunnable)
|
||||
{
|
||||
MonitorAutoLock mon(mQueueMonitor);
|
||||
AutoSetFlushing autoFlush(this);
|
||||
FlushLocked();
|
||||
nsCOMPtr<nsIRunnable> r = dont_AddRef(aRunnable.take());
|
||||
nsresult rv = DispatchLocked(r.forget(), IgnoreFlushing, AssertDispatchSuccess);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
AwaitIdleLocked();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
FlushableTaskQueue::FlushLocked()
|
||||
{
|
||||
// Make sure there are no tasks for this queue waiting in the caller's tail
|
||||
// dispatcher.
|
||||
MOZ_ASSERT_IF(AbstractThread::GetCurrent(),
|
||||
!AbstractThread::GetCurrent()->TailDispatcher().HasTasksFor(this));
|
||||
|
||||
mQueueMonitor.AssertCurrentThreadOwns();
|
||||
MOZ_ASSERT(mIsFlushing);
|
||||
|
||||
// Clear the tasks. If this strikes you as awful, stop using a
|
||||
// FlushableTaskQueue.
|
||||
while (!mTasks.empty()) {
|
||||
mTasks.pop();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TaskQueue::IsEmpty()
|
||||
{
|
||||
|
|
|
@ -175,39 +175,6 @@ protected:
|
|||
};
|
||||
};
|
||||
|
||||
class FlushableTaskQueue : public TaskQueue
|
||||
{
|
||||
public:
|
||||
explicit FlushableTaskQueue(already_AddRefed<SharedThreadPool> aPool) : TaskQueue(Move(aPool)) {}
|
||||
nsresult FlushAndDispatch(already_AddRefed<nsIRunnable> aRunnable);
|
||||
void Flush();
|
||||
|
||||
bool IsDispatchReliable() override { return false; }
|
||||
|
||||
private:
|
||||
|
||||
class MOZ_STACK_CLASS AutoSetFlushing
|
||||
{
|
||||
public:
|
||||
explicit AutoSetFlushing(FlushableTaskQueue* aTaskQueue) : mTaskQueue(aTaskQueue)
|
||||
{
|
||||
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
|
||||
mTaskQueue->mIsFlushing = true;
|
||||
}
|
||||
~AutoSetFlushing()
|
||||
{
|
||||
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
|
||||
mTaskQueue->mIsFlushing = false;
|
||||
}
|
||||
|
||||
private:
|
||||
FlushableTaskQueue* mTaskQueue;
|
||||
};
|
||||
|
||||
void FlushLocked();
|
||||
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // TaskQueue_h_
|
||||
|
|
|
@ -110,6 +110,7 @@ EXPORTS += [
|
|||
'DOMMediaStream.h',
|
||||
'EncodedBufferCache.h',
|
||||
'FileBlockCache.h',
|
||||
'FlushableTaskQueue.h',
|
||||
'Intervals.h',
|
||||
'Latency.h',
|
||||
'MediaCache.h',
|
||||
|
@ -207,6 +208,7 @@ UNIFIED_SOURCES += [
|
|||
'DOMMediaStream.cpp',
|
||||
'EncodedBufferCache.cpp',
|
||||
'FileBlockCache.cpp',
|
||||
'FlushableTaskQueue.cpp',
|
||||
'GetUserMediaRequest.cpp',
|
||||
'GraphDriver.cpp',
|
||||
'Latency.cpp',
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#if !defined(PlatformDecoderModule_h_)
|
||||
#define PlatformDecoderModule_h_
|
||||
|
||||
#include "FlushableTaskQueue.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "FlushableTaskQueue.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "nsAutoRef.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче