summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/Shared.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2005-03-08 18:10:56 +0000
committerMarc Laukien <marc@zeroc.com>2005-03-08 18:10:56 +0000
commit6359b3671c0c235167defafcb56f7931593d4058 (patch)
tree42eeae9236a2aaa96081e90e83c5b60cf52a37c6 /cpp/src/IceUtil/Shared.cpp
parentmore GCShared/Shared cleanup (diff)
downloadice-6359b3671c0c235167defafcb56f7931593d4058.tar.bz2
ice-6359b3671c0c235167defafcb56f7931593d4058.tar.xz
ice-6359b3671c0c235167defafcb56f7931593d4058.zip
fix
Diffstat (limited to 'cpp/src/IceUtil/Shared.cpp')
-rwxr-xr-xcpp/src/IceUtil/Shared.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/Shared.cpp b/cpp/src/IceUtil/Shared.cpp
new file mode 100755
index 00000000000..ba73cc7d3a3
--- /dev/null
+++ b/cpp/src/IceUtil/Shared.cpp
@@ -0,0 +1,58 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceUtil/Shared.h>
+
+using namespace IceUtil;
+
+IceUtil::SimpleShared::SimpleShared() :
+ _ref(0),
+ _noDelete(false)
+{
+}
+
+IceUtil::SimpleShared::~SimpleShared()
+{
+}
+
+IceUtil::Shared::Shared() :
+#ifndef ICE_HAS_ATOMIC_FUNCTIONS
+ _ref(0),
+#endif
+ _noDelete(false)
+{
+#ifdef ICE_HAS_ATOMIC_FUNCTIONS
+ ice_atomic_set(&_ref, 0);
+#endif
+}
+
+IceUtil::Shared::~Shared()
+{
+}
+
+int
+IceUtil::Shared::__getRef() const
+{
+#if defined(_WIN32)
+ return InterlockedExchangeAdd(const_cast<LONG*>(&_ref), 0);
+#elif defined(ICE_HAS_ATOMIC_FUNCTIONS)
+ return ice_atomic_exchange_add(0, const_cast<ice_atomic_t*>(&_ref));
+#else
+ _mutex.lock();
+ int ref = _ref;
+ _mutex.unlock();
+ return ref;
+#endif
+}
+
+void
+IceUtil::Shared::__setNoDelete(bool b)
+{
+ _noDelete = b;
+}