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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/common/sharedobject.h ('k') | source/common/simplepatternformatter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/common/sharedobject.cpp
diff --git a/source/common/sharedobject.cpp b/source/common/sharedobject.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6affcd09cd5035395b43f22cdb395db5ef845d6c
--- /dev/null
+++ b/source/common/sharedobject.cpp
@@ -0,0 +1,59 @@
+/*
+******************************************************************************
+* Copyright (C) 2014, International Business Machines
+* Corporation and others. All Rights Reserved.
+******************************************************************************
+* sharedobject.cpp
+*/
+#include "sharedobject.h"
+
+U_NAMESPACE_BEGIN
+SharedObject::~SharedObject() {}
+
+void
+SharedObject::addRef() const {
+ umtx_atomic_inc(&totalRefCount);
+}
+
+void
+SharedObject::removeRef() const {
+ if(umtx_atomic_dec(&totalRefCount) == 0) {
+ delete this;
+ }
+}
+
+void
+SharedObject::addSoftRef() const {
+ addRef();
+ umtx_atomic_inc(&softRefCount);
+}
+
+void
+SharedObject::removeSoftRef() const {
+ umtx_atomic_dec(&softRefCount);
+ removeRef();
+}
+
+UBool
+SharedObject::allSoftReferences() const {
+ return umtx_loadAcquire(totalRefCount) == umtx_loadAcquire(softRefCount);
+}
+
+int32_t
+SharedObject::getRefCount() const {
+ return umtx_loadAcquire(totalRefCount);
+}
+
+int32_t
+SharedObject::getSoftRefCount() const {
+ return umtx_loadAcquire(softRefCount);
+}
+
+void
+SharedObject::deleteIfZeroRefCount() const {
+ if(getRefCount() == 0) {
+ delete this;
+ }
+}
+
+U_NAMESPACE_END
« 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