2017-01-18 02:01:37 +03:00
|
|
|
/*
|
2019-06-20 02:58:25 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-01-18 02:01:37 +03:00
|
|
|
*
|
2019-06-20 02:58:25 +03:00
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
2017-01-18 02:01:37 +03:00
|
|
|
*/
|
2019-10-11 15:26:59 +03:00
|
|
|
|
2017-01-18 02:01:37 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains definitions of a few simple and commonly called
|
|
|
|
* InodePtrImpl methods. It is useful for callers to see the definition of
|
|
|
|
* these methods so they can be inlined.
|
|
|
|
*
|
|
|
|
* This file is included automatically by InodeBase.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "InodePtr.h"
|
|
|
|
|
|
|
|
#include "InodeBase.h"
|
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
|
|
|
template <typename InodeType>
|
|
|
|
InodePtrImpl<InodeType>::InodePtrImpl(
|
|
|
|
InodeType* value,
|
|
|
|
NormalIncrementEnum) noexcept
|
|
|
|
: value_(value) {
|
|
|
|
if (value_) {
|
|
|
|
value_->incrementPtrRef();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename InodeType>
|
|
|
|
InodePtrImpl<InodeType>::InodePtrImpl(
|
|
|
|
InodeType* value,
|
|
|
|
LockedIncrementEnum) noexcept
|
|
|
|
: value_(value) {
|
|
|
|
// We don't check for value_ == nullptr here.
|
|
|
|
// The caller should always ensure the argument is non-null for this call.
|
|
|
|
value_->newInodeRefConstructed();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename InodeType>
|
|
|
|
void InodePtrImpl<InodeType>::incref() {
|
|
|
|
if (value_) {
|
|
|
|
value_->incrementPtrRef();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename InodeType>
|
|
|
|
void InodePtrImpl<InodeType>::decref() {
|
|
|
|
if (value_) {
|
|
|
|
value_->decrementPtrRef();
|
|
|
|
}
|
|
|
|
}
|
2017-01-18 02:01:43 +03:00
|
|
|
|
|
|
|
template <typename InodeType>
|
|
|
|
void InodePtrImpl<InodeType>::manualDecRef() {
|
2020-11-11 03:29:24 +03:00
|
|
|
XCHECK_NE(value_, nullptr);
|
2017-01-18 02:01:43 +03:00
|
|
|
value_->decrementPtrRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename InodeType>
|
|
|
|
void InodePtrImpl<InodeType>::resetNoDecRef() {
|
2020-11-11 03:29:24 +03:00
|
|
|
XCHECK_NE(value_, nullptr);
|
2017-01-18 02:01:43 +03:00
|
|
|
value_ = nullptr;
|
|
|
|
}
|
2017-11-04 01:58:04 +03:00
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|