Bug 1755481: correct documentation of `nsIClipboard::getData`. r=mccr8
[gecko.git] / xpcom / threads / SchedulerGroup.h
blob8fc3005c7c001bd9a51e4ce949d89a894fc6c3df
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_SchedulerGroup_h
8 #define mozilla_SchedulerGroup_h
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/TaskCategory.h"
12 #include "mozilla/PerformanceCounter.h"
13 #include "nsCOMPtr.h"
14 #include "nsID.h"
15 #include "nsIRunnable.h"
16 #include "nsISupports.h"
17 #include "nsStringFwd.h"
18 #include "nsThreadUtils.h"
19 #include "nscore.h"
21 class nsIEventTarget;
22 class nsIRunnable;
23 class nsISerialEventTarget;
25 namespace mozilla {
26 class AbstractThread;
27 namespace dom {
28 class DocGroup;
29 } // namespace dom
31 #define NS_SCHEDULERGROUPRUNNABLE_IID \
32 { \
33 0xd31b7420, 0x872b, 0x4cfb, { \
34 0xa9, 0xc6, 0xae, 0x4c, 0x0f, 0x06, 0x36, 0x74 \
35 } \
38 class SchedulerGroup {
39 public:
40 SchedulerGroup();
42 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
44 class Runnable final : public mozilla::Runnable, public nsIRunnablePriority {
45 public:
46 Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
47 mozilla::PerformanceCounter* aPerformanceCounter);
49 mozilla::PerformanceCounter* GetPerformanceCounter() const;
51 #ifdef MOZ_COLLECTING_RUNNABLE_TELEMETRY
52 NS_IMETHOD GetName(nsACString& aName) override;
53 #endif
55 NS_DECL_ISUPPORTS_INHERITED
56 NS_DECL_NSIRUNNABLE
57 NS_DECL_NSIRUNNABLEPRIORITY
59 NS_DECLARE_STATIC_IID_ACCESSOR(NS_SCHEDULERGROUPRUNNABLE_IID);
61 private:
62 friend class SchedulerGroup;
64 ~Runnable() = default;
66 nsCOMPtr<nsIRunnable> mRunnable;
67 RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
69 friend class Runnable;
71 static nsresult Dispatch(TaskCategory aCategory,
72 already_AddRefed<nsIRunnable>&& aRunnable);
74 static nsresult UnlabeledDispatch(TaskCategory aCategory,
75 already_AddRefed<nsIRunnable>&& aRunnable);
77 static void MarkVsyncReceived();
79 static void MarkVsyncRan();
81 static nsresult LabeledDispatch(
82 TaskCategory aCategory, already_AddRefed<nsIRunnable>&& aRunnable,
83 mozilla::PerformanceCounter* aPerformanceCounter);
85 protected:
86 static nsresult InternalUnlabeledDispatch(
87 TaskCategory aCategory, already_AddRefed<Runnable>&& aRunnable);
89 // Shuts down this dispatcher. If aXPCOMShutdown is true, invalidates this
90 // dispatcher.
91 void Shutdown(bool aXPCOMShutdown);
93 bool mIsRunning;
95 // Number of events that are currently enqueued for this SchedulerGroup
96 // (across all queues).
97 size_t mEventCount = 0;
100 NS_DEFINE_STATIC_IID_ACCESSOR(SchedulerGroup::Runnable,
101 NS_SCHEDULERGROUPRUNNABLE_IID);
103 } // namespace mozilla
105 #endif // mozilla_SchedulerGroup_h