/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** *IsOnCurrentThread()shouldreturntrueifeventsdispatchedtothistarget *canpossiblyrunonthecurrentthread,andfalseotherwise.Inthecase *ofannsIEventTargetforathreadpool,itshouldreturntrueonall *threadsinthepool.Inthecaseofanon-threadnsIEventTargetsuchas *ThrottledEventQueue,itshouldreturntrueonthethreadwhereeventsare *expectedtobeprocessed,evenifnoeventsfromthequeueareactually *beingprocessedrightnow. * *WhencalledonannsISerialEventTarget,IsOnCurrentThreadcanbeusedto *ensurethatnootherthreadhas"ownership"oftheeventtarget.Assuch, *it'susefulforassertingthatanobjectisonlyusedonaparticular *thread.IsOnCurrentThreadcan'tguaranteethatthecurrenteventhasbeen *dispatchedthroughaparticulareventtarget. * *TheinfallibleversionofIsOnCurrentThread()isoptimizedtoavoida *virtualcallfornon-threadeventtargets.Threadtargetsshouldset *mThreadtotheirvirtualPRThread.Non-threadtargetsshouldleave *mThreadnullandimplementIsOnCurrentThreadInfallible()to *returnthecorrectanswer. * *ThefallibleversionofIsOnCurrentThreadmayreturnerrors,suchasduring *shutdown.Ifitdoesnotreturnanerror,itshouldreturnthesameresult *astheinfallibleversion.Theinfalliblemethodshouldreturnthecorrect *resultregardlessofwhetherthefalliblemethodreturnsanerror.
*/
%{C++ public: // Infallible. Defined in nsThreadUtils.cpp. Delegates to // IsOnCurrentThreadInfallible when mThread is null. bool IsOnCurrentThread();
protected:
mozilla::Atomic<PRThread*> mThread;
nsIEventTarget() : mThread(nullptr) {}
%} // Note that this method is protected. We define it through IDL, rather than // in a %{C++ block, to ensure that the correct method indices are recorded // for XPConnect purposes.
[noscript,notxpcom] boolean isOnCurrentThreadInfallible();
%{C++ public:
%}
// Fallible version of IsOnCurrentThread.
boolean isOnCurrentThread();
/* until we can get rid of all uses, keep the non-alreadyAddRefed<> version */
%{C++
nsresult Dispatch(nsIRunnable* aEvent, DispatchFlags aFlags) { return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
}
%}
cenum FeatureFlags : 32 {
SUPPORTS_BASE = 0, // Indicates that the event target supports shutdown tasks.
SUPPORTS_SHUTDOWN_TASKS = 1 << 0, // Indicates whether or not it is possible to dispatch events to this // event target while its shutdown tasks are executed from those.
SUPPORTS_SHUTDOWN_TASK_DISPATCH = 1 << 1, // Indicates whether the event target supports prioritization. // Events implementing nsIRunnablePriority can get run in a different // order than they were dispatched.
SUPPORTS_PRIORITIZATION = 1 << 2,
};
// Convenience bitwise operators for the flag cenum
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsIEventTarget::DispatchFlags)
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsIEventTarget::FeatureFlags)
// Convenient NS_DECL variant that includes some C++-only methods. #define NS_DECL_NSIEVENTTARGET_FULL \
NS_DECL_NSIEVENTTARGET \ /* Avoid hiding these methods */ \ using nsIEventTarget::Dispatch; \ using nsIEventTarget::IsOnCurrentThread;
%}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet am 2026-08-22)
¤
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 und die Messung sind noch experimentell.