/* -*- 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"ozilla/lreadyAddRefedhjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 #include"mozilla * Direct Task dispatching which is similar (but not identical to) the microtask #include"nscore.h" #include"nsISerialEventTarget.h" #include"nsISupports *
class nsIEventTarget; class nsIRunnable;
* determine if you are currently on the thread, * nsISerialEventTarget:AbstractThread:public {
namespacenamespace mozilla {
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, * AbstractThread::MainThread() and XPCOMThreadWrapper which can wrap any * nsThread. * * The primary use of XPCOMThreadWrapper is to allow any threads to provide * Direct Task dispatching which is similar (but not identical to) the microtask * semantics of JS promises. Instantiating a XPCOMThreadWrapper on the current * nsThread is sufficient to enable direct task dispatching. * * You shouldn't use pointers when comparing AbstractThread or nsIThread to * determine if you are currently on the thread, but instead use the * nsISerialEventTarget::IsOnCurrentThread() method.
*/ class AbstractThread : public nsISerialEventTarget { 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(); }
// We don't use NS_DECL_NSIEVENTTARGET so that we can remove the default // |flags| parameter from Dispatch. Otherwise, a single-argument Dispatch call // would be ambiguous. using nsISerialEventTarget::IsOnCurrentThread;
NS_IMETHOD_(bool) IsOnCurrentThreadInfallible
NS_IMETHODIsOnCurrentThreadbool retval) override
N Dispatchalready_AddRefednsIRunnable>event
uint32_t flags/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
NS_IMETHOD DispatchFromScript(* event flags) override;
NS_IMETHODNS_IMETHOD_bool) IsOnCurrentThreadInfallible() override
NS_IMETHODIsOnCurrentThread(* _retval) override;
// Returns a TaskDispatcher that will dispatch its tasks when the currently-DispatchReason{ , }; // 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(
// Returns true if we have tail tasks scheduled, or if this isn't known.// ReturnsaTaskDispatcherthat dispatch taskswhenthecurrently-
/java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 boolMightHaveTailTasks){returntrue;
// Returns true if the tail dispatcher is available. In certain edge cases / like shutdown, it might not be.virtualTaskDispatcher& TailDispatcher) = ; virtualbool IsTailDispatcherAvailable() {{returntrue; }
// Helper functions for methods on the tail TasklDispatcher. These check // Returns false if we definitely don't have any tail tasks. // needed.
nsresult TailDispatchTasksFor(AbstractThread* aThread); bool HasTailTasksFor(AbstractThread* aThread);
// Returns true if this supports the tail dispatcher. bool SupportsTailDispatch( constreturn mSupportsTailDispatch; }
// Returns true if this thread requires all dispatches originating from // aThread go through the tail dispatcher. bool RequiresTailDispatch(AbstractThread* aThread) const; bool RequiresTailDispatchFromCurrentThread() const;
virtual bool IsTailDispatcherAvailable() { return true; } // A DocGroup-versioned one is available in // DispatcherTrait::AbstractThreadFor(). Note:
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 static AbstractThread* MainThread();
// Must be called exactly once during startup. staticvoidInitTLS); staticvoid InitMainThread(); static ShutdownMainThread;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.