Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: webrtc/base/refcountedobject.h

Issue 2425683003: Change RefCountedObject to use perfect forwarding. (Closed)
Patch Set: git cl lint + screen_capturer_differ_wrapper.cc Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/refcount.h ('k') | webrtc/base/refcountedobject.h.pump » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // This file was GENERATED by command:
2 // pump.py refcountedobject.h.pump
3 // DO NOT EDIT BY HAND!!!
4
5 /*
6 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
7 *
8 * Use of this source code is governed by a BSD-style license
9 * that can be found in the LICENSE file in the root of the source
10 * tree. An additional intellectual property rights grant can be found
11 * in the file PATENTS. All contributing project authors may
12 * be found in the AUTHORS file in the root of the source tree.
13 */
14
15 // To generate refcount.h from refcount.h.pump, execute:
16 // ./testing/gtest/scripts/pump.py ./webrtc/base/refcountedobject.h.pump
17
18 #ifndef WEBRTC_BASE_REFCOUNTEDOBJECT_H_
19 #define WEBRTC_BASE_REFCOUNTEDOBJECT_H_
20
21 #include <utility>
22
23 #include "webrtc/base/atomicops.h"
24
25 namespace rtc {
26
27 template <class T>
28 class RefCountedObject : public T {
29 public:
30 RefCountedObject() {}
31
32 template <class P0>
33 explicit RefCountedObject(P0&& p0) : T(std::forward<P0>(p0)) {}
34 template <class P0, class P1>
35 RefCountedObject(P0&& p0, P1&& p1)
36 : T(std::forward<P0>(p0), std::forward<P1>(p1)) {}
37 template <class P0, class P1, class P2>
38 RefCountedObject(P0&& p0, P1&& p1, P2&& p2)
39 : T(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2)) {}
40 template <class P0, class P1, class P2, class P3>
41 RefCountedObject(P0&& p0, P1&& p1, P2&& p2, P3&& p3)
42 : T(std::forward<P0>(p0),
43 std::forward<P1>(p1),
44 std::forward<P2>(p2),
45 std::forward<P3>(p3)) {}
46 template <class P0, class P1, class P2, class P3, class P4>
47 RefCountedObject(P0&& p0, P1&& p1, P2&& p2, P3&& p3, P4&& p4)
48 : T(std::forward<P0>(p0),
49 std::forward<P1>(p1),
50 std::forward<P2>(p2),
51 std::forward<P3>(p3),
52 std::forward<P4>(p4)) {}
53 template <class P0, class P1, class P2, class P3, class P4, class P5>
54 RefCountedObject(P0&& p0, P1&& p1, P2&& p2, P3&& p3, P4&& p4, P5&& p5)
55 : T(std::forward<P0>(p0),
56 std::forward<P1>(p1),
57 std::forward<P2>(p2),
58 std::forward<P3>(p3),
59 std::forward<P4>(p4),
60 std::forward<P5>(p5)) {}
61 template <class P0,
62 class P1,
63 class P2,
64 class P3,
65 class P4,
66 class P5,
67 class P6>
68 RefCountedObject(P0&& p0,
69 P1&& p1,
70 P2&& p2,
71 P3&& p3,
72 P4&& p4,
73 P5&& p5,
74 P6&& p6)
75 : T(std::forward<P0>(p0),
76 std::forward<P1>(p1),
77 std::forward<P2>(p2),
78 std::forward<P3>(p3),
79 std::forward<P4>(p4),
80 std::forward<P5>(p5),
81 std::forward<P6>(p6)) {}
82 template <class P0,
83 class P1,
84 class P2,
85 class P3,
86 class P4,
87 class P5,
88 class P6,
89 class P7>
90 RefCountedObject(P0&& p0,
91 P1&& p1,
92 P2&& p2,
93 P3&& p3,
94 P4&& p4,
95 P5&& p5,
96 P6&& p6,
97 P7&& p7)
98 : T(std::forward<P0>(p0),
99 std::forward<P1>(p1),
100 std::forward<P2>(p2),
101 std::forward<P3>(p3),
102 std::forward<P4>(p4),
103 std::forward<P5>(p5),
104 std::forward<P6>(p6),
105 std::forward<P7>(p7)) {}
106 template <class P0,
107 class P1,
108 class P2,
109 class P3,
110 class P4,
111 class P5,
112 class P6,
113 class P7,
114 class P8>
115 RefCountedObject(P0&& p0,
116 P1&& p1,
117 P2&& p2,
118 P3&& p3,
119 P4&& p4,
120 P5&& p5,
121 P6&& p6,
122 P7&& p7,
123 P8&& p8)
124 : T(std::forward<P0>(p0),
125 std::forward<P1>(p1),
126 std::forward<P2>(p2),
127 std::forward<P3>(p3),
128 std::forward<P4>(p4),
129 std::forward<P5>(p5),
130 std::forward<P6>(p6),
131 std::forward<P7>(p7),
132 std::forward<P8>(p8)) {}
133 template <class P0,
134 class P1,
135 class P2,
136 class P3,
137 class P4,
138 class P5,
139 class P6,
140 class P7,
141 class P8,
142 class P9>
143 RefCountedObject(P0&& p0,
144 P1&& p1,
145 P2&& p2,
146 P3&& p3,
147 P4&& p4,
148 P5&& p5,
149 P6&& p6,
150 P7&& p7,
151 P8&& p8,
152 P9&& p9)
153 : T(std::forward<P0>(p0),
154 std::forward<P1>(p1),
155 std::forward<P2>(p2),
156 std::forward<P3>(p3),
157 std::forward<P4>(p4),
158 std::forward<P5>(p5),
159 std::forward<P6>(p6),
160 std::forward<P7>(p7),
161 std::forward<P8>(p8),
162 std::forward<P9>(p9)) {}
163 template <class P0,
164 class P1,
165 class P2,
166 class P3,
167 class P4,
168 class P5,
169 class P6,
170 class P7,
171 class P8,
172 class P9,
173 class P10>
174 RefCountedObject(P0&& p0,
175 P1&& p1,
176 P2&& p2,
177 P3&& p3,
178 P4&& p4,
179 P5&& p5,
180 P6&& p6,
181 P7&& p7,
182 P8&& p8,
183 P9&& p9,
184 P10&& p10)
185 : T(std::forward<P0>(p0),
186 std::forward<P1>(p1),
187 std::forward<P2>(p2),
188 std::forward<P3>(p3),
189 std::forward<P4>(p4),
190 std::forward<P5>(p5),
191 std::forward<P6>(p6),
192 std::forward<P7>(p7),
193 std::forward<P8>(p8),
194 std::forward<P9>(p9),
195 std::forward<P10>(p10)) {}
196
197 virtual int AddRef() const { return AtomicOps::Increment(&ref_count_); }
198
199 virtual int Release() const {
200 int count = AtomicOps::Decrement(&ref_count_);
201 if (!count) {
202 delete this;
203 }
204 return count;
205 }
206
207 // Return whether the reference count is one. If the reference count is used
208 // in the conventional way, a reference count of 1 implies that the current
209 // thread owns the reference and no other thread shares it. This call
210 // performs the test for a reference count of one, and performs the memory
211 // barrier needed for the owning thread to act on the object, knowing that it
212 // has exclusive access to the object.
213 virtual bool HasOneRef() const {
214 return AtomicOps::AcquireLoad(&ref_count_) == 1;
215 }
216
217 protected:
218 virtual ~RefCountedObject() {}
219
220 mutable volatile int ref_count_ = 0;
221 };
222
223 } // namespace rtc
224
225 #endif // WEBRTC_BASE_REFCOUNTEDOBJECT_H_
OLDNEW
« no previous file with comments | « webrtc/base/refcount.h ('k') | webrtc/base/refcountedobject.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698