mirror of
https://github.com/openharmony/drivers_framework.git
synced 2026-08-27 20:49:55 -04:00
21192b9302
Signed-off-by: yanghaizhou <yanghaizhou1@huawei.com>
28 lines
705 B
C++
28 lines
705 B
C++
/*
|
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
*
|
|
* HDF is dual licensed: you can use it either under the terms of
|
|
* the GPL, or the BSD license, at your option.
|
|
* See the LICENSE file in the root of this repository for complete details.
|
|
*/
|
|
|
|
#include "util/light_refcount_base.h"
|
|
|
|
namespace OHOS {
|
|
namespace HDI {
|
|
int LightRefCountBase::AddRef()
|
|
{
|
|
const int beforeCount = refCount_.fetch_add(1, std::memory_order_relaxed);
|
|
return beforeCount + 1;
|
|
}
|
|
|
|
int LightRefCountBase::Release()
|
|
{
|
|
const int beforeCount = refCount_.fetch_sub(1, std::memory_order_release);
|
|
if (beforeCount - 1 == 0) {
|
|
delete this;
|
|
}
|
|
return beforeCount - 1;
|
|
}
|
|
} // namespace HDI
|
|
} // namespace OHOS
|