mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
d1af43433c
- Bug 1187817. Part 1 - Move Set{Volume,PlaybackRate,PreservesPitch} to the audio thread. r=kinetik. (a234a7080)
- Bug 1187817. Part 2 - remove unused code. r=kinetik. (836c52a19)
- Bug 1187763. Part 1 - move while loop out of WaitingForAudioToPlay(). r=kinetik. (a80d70f87)
- Bug 1187763. Part 2 - extract some code of AudioLoop() into its own function. r=kinetik. (275b8bfb6)
- Bug 1187763. Part 3 - refactor AudioSink::AudioLoop into a series of events. r=kinetik (7eb3f506f)
- Bug 1187817. Part 3 - move SetPlaying to the audio thread. r=kinetik. (0fef85968)
- Bug 1187817. Part 4 - move some code in Shutdown to the audio thread. r=kinetik. (8c73fbe6d)
- Bug 1187817. Part 5 - assert some code in the audio thread and don't enter the monitor. r=kinetik. (64de4616f)
- move include (f842b4b1e)
- Bug 1163486 - Update test to use new MP4Demuxer. r=bholley (b853be477)
- Bug 1190496 - Namespace the SharedThreadPool.h include. r=cpearce (196d25d42)
- Bug 1190496 - Hoist SharedThreadPool into xpcom. r=froydnj (3dad8176f)
- Bug 1190492 - Hoist AbstractThread and TaskDispatcher to xpcom. r=froydnj (c3329fa29)
- bug 1166107 documentation of mWaitForInternalDrain thread access r=gerald (f762764b1)
- correct comment (b623b2959)
- revert demuxer check from promise reject to assert like in 1156708 (f540b270c)
- more chekcs back to asserts (7e82a0f99)
- space (733bd85a3)
- Bug 1188220: Allow disabling HW acceleration even when SharedDecoderManager isn't used. r=cpearce (909a86682)
- bug 1161903 ensure pending DrainComplete is not run after Flush() r=cpearce (648cabbb7)
- Bug 1158089 - Fall back to d3d9 DXVA if d3d11 initialization fails. r=cpearce (84b3a8e6d)
98 lines
3.7 KiB
C++
98 lines
3.7 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
/* 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/. */
|
|
|
|
#if !defined(AbstractThread_h_)
|
|
#define AbstractThread_h_
|
|
|
|
#include "nscore.h"
|
|
#include "nsIRunnable.h"
|
|
#include "nsISupportsImpl.h"
|
|
#include "nsIThread.h"
|
|
#include "mozilla/nsRefPtr.h"
|
|
|
|
#include "mozilla/ThreadLocal.h"
|
|
|
|
namespace mozilla {
|
|
|
|
class TaskQueue;
|
|
class TaskDispatcher;
|
|
|
|
/*
|
|
* We often want to run tasks on a target that guarantees that events will never
|
|
* run in parallel. There are various target types that achieve this - namely
|
|
* nsIThread and TaskQueue. Note that nsIThreadPool (which implements
|
|
* nsIEventTarget) does not have this property, so we do not want to use
|
|
* nsIEventTarget for this purpose. This class encapsulates the specifics of
|
|
* the structures we might use here and provides a consistent interface.
|
|
*
|
|
* At present, the supported AbstractThread implementations are TaskQueue
|
|
* and AbstractThread::MainThread. If you add support for another thread that is
|
|
* not the MainThread, you'll need to figure out how to make it unique such that
|
|
* comparing AbstractThread pointers is equivalent to comparing nsIThread pointers.
|
|
*/
|
|
class AbstractThread
|
|
{
|
|
public:
|
|
// Returns the AbstractThread that the caller is currently running in, or null
|
|
// if the caller is not running in an AbstractThread.
|
|
static AbstractThread* GetCurrent() { return sCurrentThreadTLS.get(); }
|
|
|
|
AbstractThread(bool aSupportsTailDispatch) : mSupportsTailDispatch(aSupportsTailDispatch) {}
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AbstractThread);
|
|
|
|
enum DispatchFailureHandling { AssertDispatchSuccess, DontAssertDispatchSuccess };
|
|
enum DispatchReason { NormalDispatch, TailDispatch };
|
|
virtual void Dispatch(already_AddRefed<nsIRunnable> aRunnable,
|
|
DispatchFailureHandling aHandling = AssertDispatchSuccess,
|
|
DispatchReason aReason = NormalDispatch) = 0;
|
|
|
|
virtual bool IsCurrentThreadIn() = 0;
|
|
|
|
// Returns true if dispatch is generally reliable. This is used to guard
|
|
// against FlushableTaskQueues, which should go away.
|
|
virtual bool IsDispatchReliable() { return true; }
|
|
|
|
// Returns a TaskDispatcher that will dispatch its tasks when the currently-
|
|
// running tasks pops off the stack.
|
|
//
|
|
// May only be called when running within the it is invoked up, and only on
|
|
// threads which support it.
|
|
virtual TaskDispatcher& TailDispatcher() = 0;
|
|
|
|
// Returns true if this supports the tail dispatcher.
|
|
bool SupportsTailDispatch() const { return mSupportsTailDispatch; }
|
|
|
|
// Returns true if this thread requires all dispatches originating from
|
|
// aThread go through the tail dispatcher.
|
|
bool RequiresTailDispatch(AbstractThread* aThread) const;
|
|
|
|
virtual TaskQueue* AsTaskQueue() { MOZ_CRASH("Not a task queue!"); }
|
|
virtual nsIThread* AsXPCOMThread() { MOZ_CRASH("Not an XPCOM thread!"); }
|
|
|
|
// Convenience method for getting an AbstractThread for the main thread.
|
|
static AbstractThread* MainThread();
|
|
|
|
// Must be called exactly once during startup.
|
|
static void InitStatics();
|
|
|
|
void DispatchStateChange(already_AddRefed<nsIRunnable> aRunnable);
|
|
|
|
static void DispatchDirectTask(already_AddRefed<nsIRunnable> aRunnable);
|
|
|
|
protected:
|
|
virtual ~AbstractThread() {}
|
|
static ThreadLocal<AbstractThread*> sCurrentThreadTLS;
|
|
|
|
// True if we want to require that every task dispatched from tasks running in
|
|
// this queue go through our queue's tail dispatcher.
|
|
const bool mSupportsTailDispatch;
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif
|