blob: b2fe7acfc406458b865abc759fa917ebfaaf3083 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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.org281cff82013-05-17 13:44:48 +000011#include "webrtc/video_engine/vie_ref_count.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000012
pbos@webrtc.org281cff82013-05-17 13:44:48 +000013#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000014
15namespace webrtc {
16
17ViERefCount::ViERefCount()
18 : count_(0),
19 crit_(CriticalSectionWrapper::CreateCriticalSection()) {
20}
21
22ViERefCount::~ViERefCount() {
23}
24
25ViERefCount& ViERefCount::operator++(int) { // NOLINT
26 CriticalSectionScoped lock(crit_.get());
27 count_++;
28 return *this;
29}
30
31ViERefCount& ViERefCount::operator--(int) { // NOLINT
32 CriticalSectionScoped lock(crit_.get());
33 count_--;
34 return *this;
35}
36
37void ViERefCount::Reset() {
38 CriticalSectionScoped lock(crit_.get());
39 count_ = 0;
40}
41
42int ViERefCount::GetCount() const {
43 return count_;
44}
45
46} // namespace webrtc