Bug 1833854 - Part 2: Common up GCSchedulingTunables invariant checks r=sfink
[gecko.git] / xpcom / threads / SchedulerGroup.h
blob76dbfb12f89a68064506db429049de745b9dae67
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 class Runnable final : public mozilla::Runnable, public nsIRunnablePriority {
41 public:
42 Runnable(already_AddRefed<nsIRunnable>&& aRunnable,
43 mozilla::PerformanceCounter* aPerformanceCounter);
45 mozilla::PerformanceCounter* GetPerformanceCounter() const;
47 #ifdef MOZ_COLLECTING_RUNNABLE_TELEMETRY
48 NS_IMETHOD GetName(nsACString& aName) override;
49 #endif
51 NS_DECL_ISUPPORTS_INHERITED
52 NS_DECL_NSIRUNNABLE
53 NS_DECL_NSIRUNNABLEPRIORITY
55 NS_DECLARE_STATIC_IID_ACCESSOR(NS_SCHEDULERGROUPRUNNABLE_IID);
57 private:
58 friend class SchedulerGroup;
60 ~Runnable() = default;
62 nsCOMPtr<nsIRunnable> mRunnable;
63 RefPtr<mozilla::PerformanceCounter> mPerformanceCounter;
65 friend class Runnable;
67 static nsresult Dispatch(TaskCategory aCategory,
68 already_AddRefed<nsIRunnable>&& aRunnable);
70 static nsresult UnlabeledDispatch(TaskCategory aCategory,
71 already_AddRefed<nsIRunnable>&& aRunnable);
73 static nsresult LabeledDispatch(
74 TaskCategory aCategory, already_AddRefed<nsIRunnable>&& aRunnable,
75 mozilla::PerformanceCounter* aPerformanceCounter);
77 protected:
78 static nsresult InternalUnlabeledDispatch(
79 TaskCategory aCategory, already_AddRefed<Runnable>&& aRunnable);
82 NS_DEFINE_STATIC_IID_ACCESSOR(SchedulerGroup::Runnable,
83 NS_SCHEDULERGROUPRUNNABLE_IID);
85 } // namespace mozilla
87 #endif // mozilla_SchedulerGroup_h