2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-06-28 06:34:08 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-05-17 13:44:48 +00:00
|
|
|
#include "webrtc/video_engine/vie_ref_count.h"
|
2011-11-29 17:31:21 +00:00
|
|
|
|
2013-05-17 13:44:48 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-11-29 17:31:21 +00:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-11-29 17:31:21 +00:00
|
|
|
ViERefCount::ViERefCount()
|
|
|
|
|
: count_(0),
|
2011-12-22 14:17:53 +00:00
|
|
|
crit_(CriticalSectionWrapper::CreateCriticalSection()) {
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-29 17:31:21 +00:00
|
|
|
ViERefCount::~ViERefCount() {
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-28 06:34:08 +00:00
|
|
|
ViERefCount& ViERefCount::operator++(int) { // NOLINT
|
2011-12-22 14:17:53 +00:00
|
|
|
CriticalSectionScoped lock(crit_.get());
|
2011-11-29 17:31:21 +00:00
|
|
|
count_++;
|
|
|
|
|
return *this;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2011-11-29 17:31:21 +00:00
|
|
|
|
2012-06-28 06:34:08 +00:00
|
|
|
ViERefCount& ViERefCount::operator--(int) { // NOLINT
|
2011-12-22 14:17:53 +00:00
|
|
|
CriticalSectionScoped lock(crit_.get());
|
2011-11-29 17:31:21 +00:00
|
|
|
count_--;
|
|
|
|
|
return *this;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2011-11-29 17:31:21 +00:00
|
|
|
|
|
|
|
|
void ViERefCount::Reset() {
|
2011-12-22 14:17:53 +00:00
|
|
|
CriticalSectionScoped lock(crit_.get());
|
2011-11-29 17:31:21 +00:00
|
|
|
count_ = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-29 17:31:21 +00:00
|
|
|
int ViERefCount::GetCount() const {
|
|
|
|
|
return count_;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2011-11-29 17:31:21 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|