1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_ScrollGeneration_h_
6 #define mozilla_ScrollGeneration_h_
13 struct ScrollGenerationCounter
;
16 class MainThreadTag
{};
18 template <typename Tag
>
19 struct ScrollGeneration
;
21 template <typename Tag
>
22 std::ostream
& operator<<(std::ostream
& aStream
,
23 const ScrollGeneration
<Tag
>& aGen
);
25 template <typename Tag
>
26 struct ScrollGeneration
{
27 friend struct ScrollGenerationCounter
;
30 // Private constructor; use ScrollGenerationCounter to get a new instance.
31 explicit ScrollGeneration(uint64_t aValue
);
34 // Dummy constructor, needed for IPDL purposes. Not intended for manual use.
37 uint64_t Raw() const { return mValue
; }
39 bool operator<(const ScrollGeneration
<Tag
>& aOther
) const;
40 bool operator==(const ScrollGeneration
<Tag
>& aOther
) const;
41 bool operator!=(const ScrollGeneration
<Tag
>& aOther
) const;
43 friend std::ostream
& operator<<<>(std::ostream
& aStream
,
44 const ScrollGeneration
<Tag
>& aGen
);
50 using APZScrollGeneration
= ScrollGeneration
<APZTag
>;
51 using MainThreadScrollGeneration
= ScrollGeneration
<MainThreadTag
>;
53 struct ScrollGenerationCounter
{
54 MainThreadScrollGeneration
NewMainThreadGeneration() {
55 uint64_t value
= ++mCounter
;
56 return MainThreadScrollGeneration(value
);
59 APZScrollGeneration
NewAPZGeneration() {
60 uint64_t value
= ++mCounter
;
61 return APZScrollGeneration(value
);
65 uint64_t mCounter
= 0;
68 } // namespace mozilla
70 #endif // mozilla_ScrollGeneration_h_