]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/sharedobject.cpp
2 ******************************************************************************
3 * Copyright (C) 2014, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************
8 #include "sharedobject.h"
11 SharedObject::~SharedObject() {}
14 SharedObject::addRef() const {
15 umtx_atomic_inc(&totalRefCount
);
19 SharedObject::removeRef() const {
20 if(umtx_atomic_dec(&totalRefCount
) == 0) {
26 SharedObject::addSoftRef() const {
28 umtx_atomic_inc(&softRefCount
);
32 SharedObject::removeSoftRef() const {
33 umtx_atomic_dec(&softRefCount
);
38 SharedObject::allSoftReferences() const {
39 return umtx_loadAcquire(totalRefCount
) == umtx_loadAcquire(softRefCount
);
43 SharedObject::getRefCount() const {
44 return umtx_loadAcquire(totalRefCount
);
48 SharedObject::getSoftRefCount() const {
49 return umtx_loadAcquire(softRefCount
);
53 SharedObject::deleteIfZeroRefCount() const {
54 if(getRefCount() == 0) {