andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | 281cff8 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 11 | #include "webrtc/video_engine/vie_ref_count.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 281cff8 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 13 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | ViERefCount::ViERefCount() |
| 18 | : count_(0), |
| 19 | crit_(CriticalSectionWrapper::CreateCriticalSection()) { |
| 20 | } |
| 21 | |
| 22 | ViERefCount::~ViERefCount() { |
| 23 | } |
| 24 | |
| 25 | ViERefCount& ViERefCount::operator++(int) { // NOLINT |
| 26 | CriticalSectionScoped lock(crit_.get()); |
| 27 | count_++; |
| 28 | return *this; |
| 29 | } |
| 30 | |
| 31 | ViERefCount& ViERefCount::operator--(int) { // NOLINT |
| 32 | CriticalSectionScoped lock(crit_.get()); |
| 33 | count_--; |
| 34 | return *this; |
| 35 | } |
| 36 | |
| 37 | void ViERefCount::Reset() { |
| 38 | CriticalSectionScoped lock(crit_.get()); |
| 39 | count_ = 0; |
| 40 | } |
| 41 | |
| 42 | int ViERefCount::GetCount() const { |
| 43 | return count_; |
| 44 | } |
| 45 | |
| 46 | } // namespace webrtc |