mirror of
https://github.com/openharmony/utils_native.git
synced 2026-08-27 03:32:46 -04:00
Executable → Regular
+6
@@ -70,6 +70,9 @@ public:
|
|||||||
|
|
||||||
bool AttemptIncStrongRef(const void *objectId, int &outCount);
|
bool AttemptIncStrongRef(const void *objectId, int &outCount);
|
||||||
|
|
||||||
|
// Only for IPC use.
|
||||||
|
bool AttemptIncStrong(const void *objectId);
|
||||||
|
|
||||||
bool IsLifeTimeExtended();
|
bool IsLifeTimeExtended();
|
||||||
|
|
||||||
void ExtendObjectLifetime();
|
void ExtendObjectLifetime();
|
||||||
@@ -140,6 +143,9 @@ public:
|
|||||||
|
|
||||||
bool AttemptIncStrongRef(const void *objectId);
|
bool AttemptIncStrongRef(const void *objectId);
|
||||||
|
|
||||||
|
// Only for IPC use.
|
||||||
|
bool AttemptIncStrong(const void *objectId);
|
||||||
|
|
||||||
bool IsAttemptAcquireSet();
|
bool IsAttemptAcquireSet();
|
||||||
|
|
||||||
bool IsExtendLifeTimeSet();
|
bool IsExtendLifeTimeSet();
|
||||||
|
|||||||
Executable → Regular
+28
@@ -245,6 +245,22 @@ ATTEMPT_SUCCESS:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RefCounter::AttemptIncStrong(const void *objectId)
|
||||||
|
{
|
||||||
|
IncWeakRefCount(objectId);
|
||||||
|
int curCount = GetStrongRefCount();
|
||||||
|
while (curCount > 0) {
|
||||||
|
if (atomicStrong_.compare_exchange_weak(curCount, curCount + 1, std::memory_order_relaxed)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
curCount = atomicStrong_.load(std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
if (curCount <= 0) {
|
||||||
|
DecWeakRefCount(objectId);
|
||||||
|
}
|
||||||
|
return curCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
RefBase::RefBase() : refs_(new RefCounter())
|
RefBase::RefBase() : refs_(new RefCounter())
|
||||||
{
|
{
|
||||||
refs_->IncRefCount();
|
refs_->IncRefCount();
|
||||||
@@ -434,6 +450,18 @@ bool RefBase::AttemptIncStrongRef(const void *objectId)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RefBase::AttemptIncStrong(const void *objectId)
|
||||||
|
{
|
||||||
|
if (refs_ == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (refs_->AttemptIncStrong(objectId)) {
|
||||||
|
refs_->SetAttemptAcquire();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool RefBase::IsAttemptAcquireSet()
|
bool RefBase::IsAttemptAcquireSet()
|
||||||
{
|
{
|
||||||
if (refs_ == nullptr) {
|
if (refs_ == nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user