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

Side by Side Diff: webrtc/system_wrappers/interface/ref_count.h

Issue 1347793005: Replace Atomic32 with webrtc/base/atomicops.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix typo Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_ 11 #ifndef SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_
12 #define SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_ 12 #define SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_
13 13
14 #include "webrtc/system_wrappers/interface/atomic32.h" 14 #include "webrtc/base/atomicops.h"
15 15
16 namespace webrtc { 16 namespace webrtc {
17 17
18 // This class can be used for instantiating 18 // This class can be used for instantiating
19 // reference counted objects. 19 // reference counted objects.
20 // int32_t AddRef() and int32_t Release(). 20 // int32_t AddRef() and int32_t Release().
21 // Usage: 21 // Usage:
22 // RefCountImpl<T>* implementation = new RefCountImpl<T>(p); 22 // RefCountImpl<T>* implementation = new RefCountImpl<T>(p);
23 // 23 //
24 // Example: 24 // Example:
(...skipping 29 matching lines...) Expand all
54 template<typename P1, typename P2, typename P3> 54 template<typename P1, typename P2, typename P3>
55 RefCountImpl(P1 p1, P2 p2, P3 p3) : T(p1, p2, p3), ref_count_(0) {} 55 RefCountImpl(P1 p1, P2 p2, P3 p3) : T(p1, p2, p3), ref_count_(0) {}
56 56
57 template<typename P1, typename P2, typename P3, typename P4> 57 template<typename P1, typename P2, typename P3, typename P4>
58 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4) : T(p1, p2, p3, p4), ref_count_(0) {} 58 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4) : T(p1, p2, p3, p4), ref_count_(0) {}
59 59
60 template<typename P1, typename P2, typename P3, typename P4, typename P5> 60 template<typename P1, typename P2, typename P3, typename P4, typename P5>
61 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 61 RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
62 : T(p1, p2, p3, p4, p5), ref_count_(0) {} 62 : T(p1, p2, p3, p4, p5), ref_count_(0) {}
63 63
64 virtual int32_t AddRef() { 64 virtual int32_t AddRef() { return rtc::AtomicOps::Increment(&ref_count_); }
65 return ++ref_count_;
66 }
67 65
68 virtual int32_t Release() { 66 virtual int32_t Release() {
69 int32_t ref_count; 67 int32_t ref_count;
70 ref_count = --ref_count_; 68 ref_count = rtc::AtomicOps::Decrement(&ref_count_);
71 if (ref_count == 0) 69 if (ref_count == 0)
72 delete this; 70 delete this;
73 return ref_count; 71 return ref_count;
74 } 72 }
75 73
76 protected: 74 protected:
77 Atomic32 ref_count_; 75 volatile int ref_count_;
78 }; 76 };
79 77
80 } // namespace webrtc 78 } // namespace webrtc
81 79
82 #endif // SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_ 80 #endif // SYSTEM_WRAPPERS_INTERFACE_REF_COUNT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698