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

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

Issue 1988183002: Reimplement PooledI420Buffer, without an extra indirection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added GetRefCount TODO comment. Created 4 years, 7 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 | « no previous file | webrtc/common_video/i420_buffer_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 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
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 virtual int Release() const { 102 virtual int Release() const {
103 int count = AtomicOps::Decrement(&ref_count_); 103 int count = AtomicOps::Decrement(&ref_count_);
104 if (!count) { 104 if (!count) {
105 delete this; 105 delete this;
106 } 106 }
107 return count; 107 return count;
108 } 108 }
109 109
110 // This call returns the reference count, and performs the memory
111 // barrier needed for the owning thread to act on the object, in
112 // case the value of the reference count implies exclusive access to
113 // the object.
114 // TODO(nisse): Currently used only by
115 // I420BufferPool::PooledI420Buffer. Consider deleting once
116 // IsMutable is deleted, see
117 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5921
118 virtual int GetRefCount() const {
119 return AtomicOps::AcquireLoad(&ref_count_);
120 }
110 // Return whether the reference count is one. If the reference count is used 121 // Return whether the reference count is one. If the reference count is used
111 // in the conventional way, a reference count of 1 implies that the current 122 // in the conventional way, a reference count of 1 implies that the current
112 // thread owns the reference and no other thread shares it. This call 123 // thread owns the reference and no other thread shares it. This call
113 // performs the test for a reference count of one, and performs the memory 124 // performs the test for a reference count of one, and performs the memory
114 // barrier needed for the owning thread to act on the object, knowing that it 125 // barrier needed for the owning thread to act on the object, knowing that it
115 // has exclusive access to the object. 126 // has exclusive access to the object.
116 virtual bool HasOneRef() const { 127 virtual bool HasOneRef() const { return GetRefCount() == 1; }
117 return AtomicOps::AcquireLoad(&ref_count_) == 1;
118 }
119 128
120 protected: 129 protected:
121 virtual ~RefCountedObject() { 130 virtual ~RefCountedObject() {
122 } 131 }
123 132
124 mutable volatile int ref_count_; 133 mutable volatile int ref_count_;
125 }; 134 };
126 135
127 } // namespace rtc 136 } // namespace rtc
128 137
129 #endif // WEBRTC_BASE_REFCOUNT_H_ 138 #endif // WEBRTC_BASE_REFCOUNT_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/common_video/i420_buffer_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698