Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: source/common/sharedobject.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/sharedobject.h ('k') | source/common/simplepatternformatter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
10 U_NAMESPACE_BEGIN
11 SharedObject::~SharedObject() {}
12
13 void
14 SharedObject::addRef() const {
15 umtx_atomic_inc(&totalRefCount);
16 }
17
18 void
19 SharedObject::removeRef() const {
20 if(umtx_atomic_dec(&totalRefCount) == 0) {
21 delete this;
22 }
23 }
24
25 void
26 SharedObject::addSoftRef() const {
27 addRef();
28 umtx_atomic_inc(&softRefCount);
29 }
30
31 void
32 SharedObject::removeSoftRef() const {
33 umtx_atomic_dec(&softRefCount);
34 removeRef();
35 }
36
37 UBool
38 SharedObject::allSoftReferences() const {
39 return umtx_loadAcquire(totalRefCount) == umtx_loadAcquire(softRefCount);
40 }
41
42 int32_t
43 SharedObject::getRefCount() const {
44 return umtx_loadAcquire(totalRefCount);
45 }
46
47 int32_t
48 SharedObject::getSoftRefCount() const {
49 return umtx_loadAcquire(softRefCount);
50 }
51
52 void
53 SharedObject::deleteIfZeroRefCount() const {
54 if(getRefCount() == 0) {
55 delete this;
56 }
57 }
58
59 U_NAMESPACE_END
OLDNEW
« no previous file with comments | « source/common/sharedobject.h ('k') | source/common/simplepatternformatter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698