]> git.saurik.com Git - apple/icu.git/blame_incremental - icuSources/common/sharedobject.cpp
ICU-531.48.tar.gz
[apple/icu.git] / icuSources / common / sharedobject.cpp
... / ...
CommitLineData
1/*
2******************************************************************************
3* Copyright (C) 2014, International Business Machines
4* Corporation and others. All Rights Reserved.
5******************************************************************************
6* sharedobject.cpp
7*/
8#include "sharedobject.h"
9
10U_NAMESPACE_BEGIN
11SharedObject::~SharedObject() {}
12
13void
14SharedObject::addRef() const {
15 umtx_atomic_inc(&refCount);
16}
17
18void
19SharedObject::removeRef() const {
20 if(umtx_atomic_dec(&refCount) == 0) {
21 delete this;
22 }
23}
24
25int32_t
26SharedObject::getRefCount() const {
27 return umtx_loadAcquire(refCount);
28}
29
30void
31SharedObject::deleteIfZeroRefCount() const {
32 if(getRefCount() == 0) {
33 delete this;
34 }
35}
36
37U_NAMESPACE_END