@dittolive/ditto 4.4.4 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DittoReactNative.podspec +27 -0
- package/README.md +68 -51
- package/node/ditto.cjs.js +1639 -851
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/ditto.win32-x64.node +0 -0
- package/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +34 -38
- package/react-native/android/CMakeLists.txt +37 -0
- package/react-native/android/build.gradle +203 -0
- package/react-native/android/cpp-adapter.cpp +254 -0
- package/react-native/android/gradle.properties +5 -0
- package/react-native/android/src/main/AndroidManifest.xml +4 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +85 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
- package/react-native/boost/boost/assert.hpp +85 -0
- package/react-native/boost/boost/config/abi/borland_prefix.hpp +27 -0
- package/react-native/boost/boost/config/abi/borland_suffix.hpp +12 -0
- package/react-native/boost/boost/config/abi/msvc_prefix.hpp +22 -0
- package/react-native/boost/boost/config/abi/msvc_suffix.hpp +8 -0
- package/react-native/boost/boost/config/abi_prefix.hpp +25 -0
- package/react-native/boost/boost/config/abi_suffix.hpp +25 -0
- package/react-native/boost/boost/config/assert_cxx03.hpp +211 -0
- package/react-native/boost/boost/config/assert_cxx11.hpp +209 -0
- package/react-native/boost/boost/config/assert_cxx14.hpp +47 -0
- package/react-native/boost/boost/config/assert_cxx17.hpp +62 -0
- package/react-native/boost/boost/config/assert_cxx20.hpp +59 -0
- package/react-native/boost/boost/config/assert_cxx98.hpp +23 -0
- package/react-native/boost/boost/config/auto_link.hpp +525 -0
- package/react-native/boost/boost/config/compiler/borland.hpp +339 -0
- package/react-native/boost/boost/config/compiler/clang.hpp +366 -0
- package/react-native/boost/boost/config/compiler/clang_version.hpp +83 -0
- package/react-native/boost/boost/config/compiler/codegear.hpp +385 -0
- package/react-native/boost/boost/config/compiler/comeau.hpp +59 -0
- package/react-native/boost/boost/config/compiler/common_edg.hpp +183 -0
- package/react-native/boost/boost/config/compiler/compaq_cxx.hpp +19 -0
- package/react-native/boost/boost/config/compiler/cray.hpp +446 -0
- package/react-native/boost/boost/config/compiler/diab.hpp +26 -0
- package/react-native/boost/boost/config/compiler/digitalmars.hpp +143 -0
- package/react-native/boost/boost/config/compiler/gcc.hpp +383 -0
- package/react-native/boost/boost/config/compiler/gcc_xml.hpp +114 -0
- package/react-native/boost/boost/config/compiler/greenhills.hpp +28 -0
- package/react-native/boost/boost/config/compiler/hp_acc.hpp +149 -0
- package/react-native/boost/boost/config/compiler/intel.hpp +577 -0
- package/react-native/boost/boost/config/compiler/kai.hpp +33 -0
- package/react-native/boost/boost/config/compiler/metrowerks.hpp +198 -0
- package/react-native/boost/boost/config/compiler/mpw.hpp +140 -0
- package/react-native/boost/boost/config/compiler/nvcc.hpp +61 -0
- package/react-native/boost/boost/config/compiler/pathscale.hpp +138 -0
- package/react-native/boost/boost/config/compiler/pgi.hpp +23 -0
- package/react-native/boost/boost/config/compiler/sgi_mipspro.hpp +29 -0
- package/react-native/boost/boost/config/compiler/sunpro_cc.hpp +222 -0
- package/react-native/boost/boost/config/compiler/vacpp.hpp +186 -0
- package/react-native/boost/boost/config/compiler/visualc.hpp +391 -0
- package/react-native/boost/boost/config/compiler/xlcpp.hpp +299 -0
- package/react-native/boost/boost/config/compiler/xlcpp_zos.hpp +173 -0
- package/react-native/boost/boost/config/detail/cxx_composite.hpp +203 -0
- package/react-native/boost/boost/config/detail/posix_features.hpp +95 -0
- package/react-native/boost/boost/config/detail/select_compiler_config.hpp +157 -0
- package/react-native/boost/boost/config/detail/select_platform_config.hpp +147 -0
- package/react-native/boost/boost/config/detail/select_stdlib_config.hpp +121 -0
- package/react-native/boost/boost/config/detail/suffix.hpp +1294 -0
- package/react-native/boost/boost/config/header_deprecated.hpp +26 -0
- package/react-native/boost/boost/config/helper_macros.hpp +37 -0
- package/react-native/boost/boost/config/no_tr1/cmath.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/complex.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/functional.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/memory.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/utility.hpp +28 -0
- package/react-native/boost/boost/config/platform/aix.hpp +33 -0
- package/react-native/boost/boost/config/platform/amigaos.hpp +15 -0
- package/react-native/boost/boost/config/platform/beos.hpp +26 -0
- package/react-native/boost/boost/config/platform/bsd.hpp +83 -0
- package/react-native/boost/boost/config/platform/cloudabi.hpp +18 -0
- package/react-native/boost/boost/config/platform/cray.hpp +18 -0
- package/react-native/boost/boost/config/platform/cygwin.hpp +71 -0
- package/react-native/boost/boost/config/platform/haiku.hpp +31 -0
- package/react-native/boost/boost/config/platform/hpux.hpp +87 -0
- package/react-native/boost/boost/config/platform/irix.hpp +31 -0
- package/react-native/boost/boost/config/platform/linux.hpp +106 -0
- package/react-native/boost/boost/config/platform/macos.hpp +87 -0
- package/react-native/boost/boost/config/platform/qnxnto.hpp +31 -0
- package/react-native/boost/boost/config/platform/solaris.hpp +31 -0
- package/react-native/boost/boost/config/platform/symbian.hpp +97 -0
- package/react-native/boost/boost/config/platform/vms.hpp +25 -0
- package/react-native/boost/boost/config/platform/vxworks.hpp +422 -0
- package/react-native/boost/boost/config/platform/wasm.hpp +23 -0
- package/react-native/boost/boost/config/platform/win32.hpp +90 -0
- package/react-native/boost/boost/config/platform/zos.hpp +32 -0
- package/react-native/boost/boost/config/pragma_message.hpp +31 -0
- package/react-native/boost/boost/config/requires_threads.hpp +92 -0
- package/react-native/boost/boost/config/stdlib/dinkumware.hpp +324 -0
- package/react-native/boost/boost/config/stdlib/libcomo.hpp +93 -0
- package/react-native/boost/boost/config/stdlib/libcpp.hpp +180 -0
- package/react-native/boost/boost/config/stdlib/libstdcpp3.hpp +482 -0
- package/react-native/boost/boost/config/stdlib/modena.hpp +79 -0
- package/react-native/boost/boost/config/stdlib/msl.hpp +98 -0
- package/react-native/boost/boost/config/stdlib/roguewave.hpp +208 -0
- package/react-native/boost/boost/config/stdlib/sgi.hpp +168 -0
- package/react-native/boost/boost/config/stdlib/stlport.hpp +258 -0
- package/react-native/boost/boost/config/stdlib/vacpp.hpp +74 -0
- package/react-native/boost/boost/config/stdlib/xlcpp_zos.hpp +61 -0
- package/react-native/boost/boost/config/user.hpp +133 -0
- package/react-native/boost/boost/config/warning_disable.hpp +47 -0
- package/react-native/boost/boost/config/workaround.hpp +305 -0
- package/react-native/boost/boost/config.hpp +67 -0
- package/react-native/boost/boost/cstdint.hpp +556 -0
- package/react-native/boost/boost/intrusive_ptr.hpp +18 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count.hpp +103 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc.hpp +79 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp +63 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +88 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_nt.hpp +66 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_pt.hpp +104 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_spin.hpp +69 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_std_atomic.hpp +67 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_sync.hpp +72 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_win32.hpp +70 -0
- package/react-native/boost/boost/smart_ptr/detail/local_counted_base.hpp +148 -0
- package/react-native/boost/boost/smart_ptr/detail/local_sp_deleter.hpp +91 -0
- package/react-native/boost/boost/smart_ptr/detail/operator_bool.hpp +64 -0
- package/react-native/boost/boost/smart_ptr/detail/requires_cxx11.hpp +23 -0
- package/react-native/boost/boost/smart_ptr/detail/shared_count.hpp +707 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_convertible.hpp +92 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base.hpp +92 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +163 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_aix.hpp +152 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +185 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp +148 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +170 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +200 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +194 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +179 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +186 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_nt.hpp +119 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_pt.hpp +147 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +174 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_spin.hpp +141 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +147 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp +165 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +163 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_w32.hpp +140 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_impl.hpp +309 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_disable_deprecated.hpp +40 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_forward.hpp +52 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp +27 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp +69 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_interlocked.hpp +173 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_noexcept.hpp +48 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_nullptr_t.hpp +45 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_obsolete.hpp +32 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_thread_pause.hpp +51 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_thread_sleep.hpp +104 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_thread_yield.hpp +100 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_typeinfo_.hpp +58 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_win32_sleep.hpp +49 -0
- package/react-native/boost/boost/smart_ptr/intrusive_ptr.hpp +409 -0
- package/react-native/boost/boost/smart_ptr/intrusive_ref_counter.hpp +188 -0
- package/react-native/cpp/include/Attachment.h +16 -0
- package/react-native/cpp/include/Authentication.h +23 -0
- package/react-native/cpp/include/Collection.h +13 -0
- package/react-native/cpp/include/DQL.h +21 -0
- package/react-native/cpp/include/Document.h +17 -0
- package/react-native/cpp/include/Identity.h +17 -0
- package/react-native/cpp/include/Lifecycle.h +16 -0
- package/react-native/cpp/include/LiveQuery.h +17 -0
- package/react-native/cpp/include/Logger.h +22 -0
- package/react-native/cpp/include/Misc.h +26 -0
- package/react-native/cpp/include/Presence.h +14 -0
- package/react-native/cpp/include/RetainableState.h +24 -0
- package/react-native/cpp/include/SmallPeerInfo.h +17 -0
- package/react-native/cpp/include/Transports.h +25 -0
- package/react-native/cpp/include/TypedArray.hpp +167 -0
- package/react-native/cpp/include/Utils.h +61 -0
- package/react-native/cpp/include/main.h +10 -0
- package/react-native/cpp/src/Attachment.cpp +86 -0
- package/react-native/cpp/src/Authentication.cpp +224 -0
- package/react-native/cpp/src/Collection.cpp +54 -0
- package/react-native/cpp/src/DQL.cpp +254 -0
- package/react-native/cpp/src/Document.cpp +146 -0
- package/react-native/cpp/src/Identity.cpp +123 -0
- package/react-native/cpp/src/Lifecycle.cpp +75 -0
- package/react-native/cpp/src/LiveQuery.cpp +64 -0
- package/react-native/cpp/src/Logger.cpp +200 -0
- package/react-native/cpp/src/Misc.cpp +271 -0
- package/react-native/cpp/src/Presence.cpp +77 -0
- package/react-native/cpp/src/RetainableState.cpp +15 -0
- package/react-native/cpp/src/SmallPeerInfo.cpp +108 -0
- package/react-native/cpp/src/Transports.cpp +270 -0
- package/react-native/cpp/src/TypedArray.cpp +303 -0
- package/react-native/cpp/src/Utils.cpp +138 -0
- package/react-native/cpp/src/main.cpp +149 -0
- package/react-native/dittoffi/dittoffi.h +4698 -0
- package/react-native/dittoffi/ifaddrs.cpp +385 -0
- package/react-native/dittoffi/ifaddrs.h +206 -0
- package/react-native/ios/DittoRNSDK.h +7 -0
- package/react-native/ios/DittoRNSDK.mm +107 -0
- package/react-native/ios/YeetJSIUtils.h +60 -0
- package/react-native/ios/YeetJSIUtils.mm +196 -0
- package/react-native/lib/commonjs/ditto.rn.js +93 -0
- package/react-native/lib/commonjs/ditto.rn.js.map +1 -0
- package/react-native/lib/commonjs/index.js +14 -0
- package/react-native/lib/commonjs/index.js.map +1 -0
- package/react-native/lib/module/ditto.rn.js +83 -0
- package/react-native/lib/module/ditto.rn.js.map +1 -0
- package/react-native/lib/module/index.js +13 -0
- package/react-native/lib/module/index.js.map +1 -0
- package/react-native/lib/typescript/ditto.rn.d.ts +15 -0
- package/react-native/lib/typescript/ditto.rn.d.ts.map +1 -0
- package/react-native/lib/typescript/index.d.ts +1 -0
- package/react-native/lib/typescript/index.d.ts.map +1 -0
- package/react-native/scripts/ruby/include_local_boost.rb +78 -0
- package/react-native/src/ditto.rn.ts +91 -0
- package/react-native/src/environment/environment.fallback.ts +4 -0
- package/react-native/src/index.ts +26 -0
- package/react-native/src/sources/@cbor-redux.ts +2 -0
- package/react-native/src/sources/@ditto.core.ts +1 -0
- package/react-native/src/sources/@environment.ts +2 -0
- package/react-native/src/sources/attachment-fetch-event.ts +54 -0
- package/react-native/src/sources/attachment-fetcher-manager.ts +129 -0
- package/react-native/src/sources/attachment-fetcher.ts +124 -0
- package/react-native/src/sources/attachment-token.ts +48 -0
- package/react-native/src/sources/attachment.ts +59 -0
- package/react-native/src/sources/augment.ts +89 -0
- package/react-native/src/sources/authenticator.ts +314 -0
- package/react-native/src/sources/base-pending-cursor-operation.ts +237 -0
- package/react-native/src/sources/base-pending-id-specific-operation.ts +109 -0
- package/react-native/src/sources/bridge.ts +549 -0
- package/react-native/src/sources/build-time-constants.ts +4 -0
- package/react-native/src/sources/cbor.ts +35 -0
- package/react-native/src/sources/collection-interface.ts +67 -0
- package/react-native/src/sources/collection.ts +212 -0
- package/react-native/src/sources/collections-event.ts +99 -0
- package/react-native/src/sources/counter.ts +77 -0
- package/react-native/src/sources/ditto.ts +945 -0
- package/react-native/src/sources/document-id.ts +159 -0
- package/react-native/src/sources/document-path.ts +303 -0
- package/react-native/src/sources/document.ts +192 -0
- package/react-native/src/sources/epilogue.ts +24 -0
- package/react-native/src/sources/error-codes.ts +52 -0
- package/react-native/src/sources/error.ts +203 -0
- package/react-native/src/sources/essentials.ts +53 -0
- package/react-native/src/sources/ffi-error.ts +117 -0
- package/react-native/src/sources/ffi.ts +1972 -0
- package/react-native/src/sources/identity.ts +163 -0
- package/react-native/src/sources/init.ts +70 -0
- package/react-native/src/sources/internal.ts +113 -0
- package/react-native/src/sources/keep-alive.ts +69 -0
- package/react-native/src/sources/key-path.ts +195 -0
- package/react-native/src/sources/live-query-event.ts +208 -0
- package/react-native/src/sources/live-query-manager.ts +101 -0
- package/react-native/src/sources/live-query.ts +164 -0
- package/react-native/src/sources/logger.ts +196 -0
- package/react-native/src/sources/observer-manager.ts +175 -0
- package/react-native/src/sources/observer.ts +77 -0
- package/react-native/src/sources/pending-collections-operation.ts +232 -0
- package/react-native/src/sources/pending-cursor-operation.ts +218 -0
- package/react-native/src/sources/pending-id-specific-operation.ts +216 -0
- package/react-native/src/sources/presence-manager.ts +160 -0
- package/react-native/src/sources/presence.ts +238 -0
- package/react-native/src/sources/query-result-item.ts +116 -0
- package/react-native/src/sources/query-result.ts +55 -0
- package/react-native/src/sources/register.ts +92 -0
- package/react-native/src/sources/small-peer-info.ts +176 -0
- package/react-native/src/sources/static-tcp-client.ts +6 -0
- package/react-native/src/sources/store-observer.ts +176 -0
- package/react-native/src/sources/store.ts +365 -0
- package/react-native/src/sources/subscription-manager.ts +98 -0
- package/react-native/src/sources/subscription.ts +88 -0
- package/react-native/src/sources/sync-subscription.ts +90 -0
- package/react-native/src/sources/sync.ts +495 -0
- package/react-native/src/sources/test-helpers.ts +24 -0
- package/react-native/src/sources/transport-conditions-manager.ts +104 -0
- package/react-native/src/sources/transport-config.ts +428 -0
- package/react-native/src/sources/update-result.ts +66 -0
- package/react-native/src/sources/update-results-map.ts +57 -0
- package/react-native/src/sources/websocket-client.ts +6 -0
- package/react-native/src/sources/write-transaction-collection.ts +122 -0
- package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +101 -0
- package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +72 -0
- package/react-native/src/sources/write-transaction.ts +119 -0
- package/react-native.config.js +9 -0
- package/types/ditto.d.ts +1230 -798
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_ATOMIC_HPP_INCLUDED
|
|
2
|
+
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_ATOMIC_HPP_INCLUDED
|
|
3
|
+
|
|
4
|
+
// MS compatible compilers support #pragma once
|
|
5
|
+
|
|
6
|
+
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
7
|
+
# pragma once
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
// detail/sp_counted_base_gcc_atomic.hpp - g++ 4.7+ __atomic intrinsics
|
|
11
|
+
//
|
|
12
|
+
// Copyright 2007, 2020 Peter Dimov
|
|
13
|
+
// Distributed under the Boost Software License, Version 1.0.
|
|
14
|
+
// https://www.boost.org/LICENSE_1_0.txt
|
|
15
|
+
|
|
16
|
+
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
|
|
17
|
+
#include <boost/config.hpp>
|
|
18
|
+
#include <boost/cstdint.hpp>
|
|
19
|
+
|
|
20
|
+
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
|
21
|
+
|
|
22
|
+
#include <boost/config/pragma_message.hpp>
|
|
23
|
+
BOOST_PRAGMA_MESSAGE("Using __atomic sp_counted_base")
|
|
24
|
+
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
namespace boost
|
|
28
|
+
{
|
|
29
|
+
|
|
30
|
+
namespace detail
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
inline void atomic_increment( boost::uint_least32_t * pw )
|
|
34
|
+
{
|
|
35
|
+
__atomic_fetch_add( pw, 1, __ATOMIC_RELAXED );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
inline boost::uint_least32_t atomic_decrement( boost::uint_least32_t * pw )
|
|
39
|
+
{
|
|
40
|
+
return __atomic_fetch_sub( pw, 1, __ATOMIC_ACQ_REL );
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
inline boost::uint_least32_t atomic_conditional_increment( boost::uint_least32_t * pw )
|
|
44
|
+
{
|
|
45
|
+
// long r = *pw;
|
|
46
|
+
// if( r != 0 ) ++*pw;
|
|
47
|
+
// return r;
|
|
48
|
+
|
|
49
|
+
boost::uint_least32_t r = __atomic_load_n( pw, __ATOMIC_RELAXED );
|
|
50
|
+
|
|
51
|
+
for( ;; )
|
|
52
|
+
{
|
|
53
|
+
if( r == 0 )
|
|
54
|
+
{
|
|
55
|
+
return r;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if( __atomic_compare_exchange_n( pw, &r, r + 1, true, __ATOMIC_RELAXED, __ATOMIC_RELAXED ) )
|
|
59
|
+
{
|
|
60
|
+
return r;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
inline boost::uint_least32_t atomic_load( boost::uint_least32_t const * pw )
|
|
66
|
+
{
|
|
67
|
+
return __atomic_load_n( pw, __ATOMIC_ACQUIRE );
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
|
71
|
+
{
|
|
72
|
+
private:
|
|
73
|
+
|
|
74
|
+
sp_counted_base( sp_counted_base const & );
|
|
75
|
+
sp_counted_base & operator= ( sp_counted_base const & );
|
|
76
|
+
|
|
77
|
+
boost::uint_least32_t use_count_; // #shared
|
|
78
|
+
boost::uint_least32_t weak_count_; // #weak + (#shared != 0)
|
|
79
|
+
|
|
80
|
+
public:
|
|
81
|
+
|
|
82
|
+
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
|
|
83
|
+
{
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
virtual ~sp_counted_base() // nothrow
|
|
87
|
+
{
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// dispose() is called when use_count_ drops to zero, to release
|
|
91
|
+
// the resources managed by *this.
|
|
92
|
+
|
|
93
|
+
virtual void dispose() = 0; // nothrow
|
|
94
|
+
|
|
95
|
+
// destroy() is called when weak_count_ drops to zero.
|
|
96
|
+
|
|
97
|
+
virtual void destroy() // nothrow
|
|
98
|
+
{
|
|
99
|
+
delete this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
103
|
+
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
104
|
+
virtual void * get_untyped_deleter() = 0;
|
|
105
|
+
|
|
106
|
+
void add_ref_copy()
|
|
107
|
+
{
|
|
108
|
+
atomic_increment( &use_count_ );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
bool add_ref_lock() // true on success
|
|
112
|
+
{
|
|
113
|
+
return atomic_conditional_increment( &use_count_ ) != 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void release() // nothrow
|
|
117
|
+
{
|
|
118
|
+
if( atomic_decrement( &use_count_ ) == 1 )
|
|
119
|
+
{
|
|
120
|
+
dispose();
|
|
121
|
+
weak_release();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void weak_add_ref() // nothrow
|
|
126
|
+
{
|
|
127
|
+
atomic_increment( &weak_count_ );
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void weak_release() // nothrow
|
|
131
|
+
{
|
|
132
|
+
if( atomic_decrement( &weak_count_ ) == 1 )
|
|
133
|
+
{
|
|
134
|
+
destroy();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
long use_count() const // nothrow
|
|
139
|
+
{
|
|
140
|
+
return atomic_load( &use_count_ );
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
} // namespace detail
|
|
145
|
+
|
|
146
|
+
} // namespace boost
|
|
147
|
+
|
|
148
|
+
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SYNC_HPP_INCLUDED
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
|
|
2
|
+
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// detail/sp_counted_base_gcc_ia64.hpp - g++ on IA64
|
|
6
|
+
//
|
|
7
|
+
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
|
|
8
|
+
// Copyright 2004-2006 Peter Dimov
|
|
9
|
+
// Copyright 2005 Ben Hutchings
|
|
10
|
+
//
|
|
11
|
+
// Distributed under the Boost Software License, Version 1.0. (See
|
|
12
|
+
// accompanying file LICENSE_1_0.txt or copy at
|
|
13
|
+
// http://www.boost.org/LICENSE_1_0.txt)
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
// Lock-free algorithm by Alexander Terekhov
|
|
17
|
+
//
|
|
18
|
+
|
|
19
|
+
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
|
|
20
|
+
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
|
|
21
|
+
#include <boost/config.hpp>
|
|
22
|
+
|
|
23
|
+
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
|
24
|
+
|
|
25
|
+
#include <boost/config/pragma_message.hpp>
|
|
26
|
+
BOOST_PRAGMA_MESSAGE("Using g++/IA64 sp_counted_base")
|
|
27
|
+
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
BOOST_SP_OBSOLETE()
|
|
31
|
+
|
|
32
|
+
namespace boost
|
|
33
|
+
{
|
|
34
|
+
|
|
35
|
+
namespace detail
|
|
36
|
+
{
|
|
37
|
+
|
|
38
|
+
inline void atomic_increment( int * pw )
|
|
39
|
+
{
|
|
40
|
+
// ++*pw;
|
|
41
|
+
|
|
42
|
+
int tmp;
|
|
43
|
+
|
|
44
|
+
// No barrier is required here but fetchadd always has an acquire or
|
|
45
|
+
// release barrier associated with it. We choose release as it should be
|
|
46
|
+
// cheaper.
|
|
47
|
+
__asm__ ("fetchadd4.rel %0=%1,1" :
|
|
48
|
+
"=r"(tmp), "=m"(*pw) :
|
|
49
|
+
"m"( *pw ));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
inline int atomic_decrement( int * pw )
|
|
53
|
+
{
|
|
54
|
+
// return --*pw;
|
|
55
|
+
|
|
56
|
+
int rv;
|
|
57
|
+
|
|
58
|
+
__asm__ (" fetchadd4.rel %0=%1,-1 ;; \n"
|
|
59
|
+
" cmp.eq p7,p0=1,%0 ;; \n"
|
|
60
|
+
"(p7) ld4.acq %0=%1 " :
|
|
61
|
+
"=&r"(rv), "=m"(*pw) :
|
|
62
|
+
"m"( *pw ) :
|
|
63
|
+
"p7");
|
|
64
|
+
|
|
65
|
+
return rv;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
inline int atomic_conditional_increment( int * pw )
|
|
69
|
+
{
|
|
70
|
+
// if( *pw != 0 ) ++*pw;
|
|
71
|
+
// return *pw;
|
|
72
|
+
|
|
73
|
+
int rv, tmp, tmp2;
|
|
74
|
+
|
|
75
|
+
__asm__ ("0: ld4 %0=%3 ;; \n"
|
|
76
|
+
" cmp.eq p7,p0=0,%0 ;; \n"
|
|
77
|
+
"(p7) br.cond.spnt 1f \n"
|
|
78
|
+
" mov ar.ccv=%0 \n"
|
|
79
|
+
" add %1=1,%0 ;; \n"
|
|
80
|
+
" cmpxchg4.acq %2=%3,%1,ar.ccv ;; \n"
|
|
81
|
+
" cmp.ne p7,p0=%0,%2 ;; \n"
|
|
82
|
+
"(p7) br.cond.spnt 0b \n"
|
|
83
|
+
" mov %0=%1 ;; \n"
|
|
84
|
+
"1:" :
|
|
85
|
+
"=&r"(rv), "=&r"(tmp), "=&r"(tmp2), "=m"(*pw) :
|
|
86
|
+
"m"( *pw ) :
|
|
87
|
+
"ar.ccv", "p7");
|
|
88
|
+
|
|
89
|
+
return rv;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
|
93
|
+
{
|
|
94
|
+
private:
|
|
95
|
+
|
|
96
|
+
sp_counted_base( sp_counted_base const & );
|
|
97
|
+
sp_counted_base & operator= ( sp_counted_base const & );
|
|
98
|
+
|
|
99
|
+
int use_count_; // #shared
|
|
100
|
+
int weak_count_; // #weak + (#shared != 0)
|
|
101
|
+
|
|
102
|
+
public:
|
|
103
|
+
|
|
104
|
+
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
|
|
105
|
+
{
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
virtual ~sp_counted_base() // nothrow
|
|
109
|
+
{
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// dispose() is called when use_count_ drops to zero, to release
|
|
113
|
+
// the resources managed by *this.
|
|
114
|
+
|
|
115
|
+
virtual void dispose() = 0; // nothrow
|
|
116
|
+
|
|
117
|
+
// destroy() is called when weak_count_ drops to zero.
|
|
118
|
+
|
|
119
|
+
virtual void destroy() // nothrow
|
|
120
|
+
{
|
|
121
|
+
delete this;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
125
|
+
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
126
|
+
virtual void * get_untyped_deleter() = 0;
|
|
127
|
+
|
|
128
|
+
void add_ref_copy()
|
|
129
|
+
{
|
|
130
|
+
atomic_increment( &use_count_ );
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
bool add_ref_lock() // true on success
|
|
134
|
+
{
|
|
135
|
+
return atomic_conditional_increment( &use_count_ ) != 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
void release() // nothrow
|
|
139
|
+
{
|
|
140
|
+
if( atomic_decrement( &use_count_ ) == 0 )
|
|
141
|
+
{
|
|
142
|
+
dispose();
|
|
143
|
+
weak_release();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
void weak_add_ref() // nothrow
|
|
148
|
+
{
|
|
149
|
+
atomic_increment( &weak_count_ );
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
void weak_release() // nothrow
|
|
153
|
+
{
|
|
154
|
+
if( atomic_decrement( &weak_count_ ) == 0 )
|
|
155
|
+
{
|
|
156
|
+
destroy();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
long use_count() const // nothrow
|
|
161
|
+
{
|
|
162
|
+
return static_cast<int const volatile &>( use_count_ ); // TODO use ld.acq here
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
} // namespace detail
|
|
167
|
+
|
|
168
|
+
} // namespace boost
|
|
169
|
+
|
|
170
|
+
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_IA64_HPP_INCLUDED
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
|
|
2
|
+
#define BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
|
|
3
|
+
|
|
4
|
+
// MS compatible compilers support #pragma once
|
|
5
|
+
|
|
6
|
+
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
7
|
+
# pragma once
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
// detail/sp_counted_base_gcc_mips.hpp - g++ on MIPS
|
|
12
|
+
//
|
|
13
|
+
// Copyright (c) 2009, Spirent Communications, Inc.
|
|
14
|
+
//
|
|
15
|
+
// Distributed under the Boost Software License, Version 1.0. (See
|
|
16
|
+
// accompanying file LICENSE_1_0.txt or copy at
|
|
17
|
+
// http://www.boost.org/LICENSE_1_0.txt)
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
// Lock-free algorithm by Alexander Terekhov
|
|
21
|
+
//
|
|
22
|
+
|
|
23
|
+
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
|
|
24
|
+
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
|
|
25
|
+
#include <boost/config.hpp>
|
|
26
|
+
|
|
27
|
+
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
|
28
|
+
|
|
29
|
+
#include <boost/config/pragma_message.hpp>
|
|
30
|
+
BOOST_PRAGMA_MESSAGE("Using g++/MIPS sp_counted_base")
|
|
31
|
+
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
BOOST_SP_OBSOLETE()
|
|
35
|
+
|
|
36
|
+
namespace boost
|
|
37
|
+
{
|
|
38
|
+
|
|
39
|
+
namespace detail
|
|
40
|
+
{
|
|
41
|
+
|
|
42
|
+
inline void atomic_increment( int * pw )
|
|
43
|
+
{
|
|
44
|
+
// ++*pw;
|
|
45
|
+
|
|
46
|
+
int tmp;
|
|
47
|
+
|
|
48
|
+
__asm__ __volatile__
|
|
49
|
+
(
|
|
50
|
+
"0:\n\t"
|
|
51
|
+
".set push\n\t"
|
|
52
|
+
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
|
|
53
|
+
".set mips2\n\t"
|
|
54
|
+
#endif
|
|
55
|
+
"ll %0, %1\n\t"
|
|
56
|
+
"addiu %0, 1\n\t"
|
|
57
|
+
"sc %0, %1\n\t"
|
|
58
|
+
".set pop\n\t"
|
|
59
|
+
"beqz %0, 0b":
|
|
60
|
+
"=&r"( tmp ), "=m"( *pw ):
|
|
61
|
+
"m"( *pw )
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
inline int atomic_decrement( int * pw )
|
|
66
|
+
{
|
|
67
|
+
// return --*pw;
|
|
68
|
+
|
|
69
|
+
int rv, tmp;
|
|
70
|
+
|
|
71
|
+
__asm__ __volatile__
|
|
72
|
+
(
|
|
73
|
+
"0:\n\t"
|
|
74
|
+
".set push\n\t"
|
|
75
|
+
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
|
|
76
|
+
".set mips2\n\t"
|
|
77
|
+
#endif
|
|
78
|
+
"ll %1, %2\n\t"
|
|
79
|
+
"addiu %0, %1, -1\n\t"
|
|
80
|
+
"sc %0, %2\n\t"
|
|
81
|
+
".set pop\n\t"
|
|
82
|
+
"beqz %0, 0b\n\t"
|
|
83
|
+
"addiu %0, %1, -1":
|
|
84
|
+
"=&r"( rv ), "=&r"( tmp ), "=m"( *pw ):
|
|
85
|
+
"m"( *pw ):
|
|
86
|
+
"memory"
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return rv;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
inline int atomic_conditional_increment( int * pw )
|
|
93
|
+
{
|
|
94
|
+
// if( *pw != 0 ) ++*pw;
|
|
95
|
+
// return *pw;
|
|
96
|
+
|
|
97
|
+
int rv, tmp;
|
|
98
|
+
|
|
99
|
+
__asm__ __volatile__
|
|
100
|
+
(
|
|
101
|
+
"0:\n\t"
|
|
102
|
+
".set push\n\t"
|
|
103
|
+
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
|
|
104
|
+
".set mips2\n\t"
|
|
105
|
+
#endif
|
|
106
|
+
"ll %0, %2\n\t"
|
|
107
|
+
"beqz %0, 1f\n\t"
|
|
108
|
+
"addiu %1, %0, 1\n\t"
|
|
109
|
+
"sc %1, %2\n\t"
|
|
110
|
+
".set pop\n\t"
|
|
111
|
+
"beqz %1, 0b\n\t"
|
|
112
|
+
"addiu %0, %0, 1\n\t"
|
|
113
|
+
"1:":
|
|
114
|
+
"=&r"( rv ), "=&r"( tmp ), "=m"( *pw ):
|
|
115
|
+
"m"( *pw ):
|
|
116
|
+
"memory"
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return rv;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
|
123
|
+
{
|
|
124
|
+
private:
|
|
125
|
+
|
|
126
|
+
sp_counted_base( sp_counted_base const & );
|
|
127
|
+
sp_counted_base & operator= ( sp_counted_base const & );
|
|
128
|
+
|
|
129
|
+
int use_count_; // #shared
|
|
130
|
+
int weak_count_; // #weak + (#shared != 0)
|
|
131
|
+
|
|
132
|
+
public:
|
|
133
|
+
|
|
134
|
+
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
|
|
135
|
+
{
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
virtual ~sp_counted_base() // nothrow
|
|
139
|
+
{
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// dispose() is called when use_count_ drops to zero, to release
|
|
143
|
+
// the resources managed by *this.
|
|
144
|
+
|
|
145
|
+
virtual void dispose() = 0; // nothrow
|
|
146
|
+
|
|
147
|
+
// destroy() is called when weak_count_ drops to zero.
|
|
148
|
+
|
|
149
|
+
virtual void destroy() // nothrow
|
|
150
|
+
{
|
|
151
|
+
delete this;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
155
|
+
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
156
|
+
virtual void * get_untyped_deleter() = 0;
|
|
157
|
+
|
|
158
|
+
void add_ref_copy()
|
|
159
|
+
{
|
|
160
|
+
atomic_increment( &use_count_ );
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
bool add_ref_lock() // true on success
|
|
164
|
+
{
|
|
165
|
+
return atomic_conditional_increment( &use_count_ ) != 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
void release() // nothrow
|
|
169
|
+
{
|
|
170
|
+
if( atomic_decrement( &use_count_ ) == 0 )
|
|
171
|
+
{
|
|
172
|
+
dispose();
|
|
173
|
+
weak_release();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
void weak_add_ref() // nothrow
|
|
178
|
+
{
|
|
179
|
+
atomic_increment( &weak_count_ );
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void weak_release() // nothrow
|
|
183
|
+
{
|
|
184
|
+
if( atomic_decrement( &weak_count_ ) == 0 )
|
|
185
|
+
{
|
|
186
|
+
destroy();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
long use_count() const // nothrow
|
|
191
|
+
{
|
|
192
|
+
return static_cast<int const volatile &>( use_count_ );
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
} // namespace detail
|
|
197
|
+
|
|
198
|
+
} // namespace boost
|
|
199
|
+
|
|
200
|
+
#endif // #ifndef BOOST_DETAIL_SP_COUNTED_BASE_GCC_MIPS_HPP_INCLUDED
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
|
|
2
|
+
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
|
|
3
|
+
|
|
4
|
+
// MS compatible compilers support #pragma once
|
|
5
|
+
|
|
6
|
+
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
7
|
+
# pragma once
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
// detail/sp_counted_base_gcc_ppc.hpp - g++ on PowerPC
|
|
12
|
+
//
|
|
13
|
+
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
|
|
14
|
+
// Copyright 2004-2005 Peter Dimov
|
|
15
|
+
//
|
|
16
|
+
// Distributed under the Boost Software License, Version 1.0. (See
|
|
17
|
+
// accompanying file LICENSE_1_0.txt or copy at
|
|
18
|
+
// http://www.boost.org/LICENSE_1_0.txt)
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
// Lock-free algorithm by Alexander Terekhov
|
|
22
|
+
//
|
|
23
|
+
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
|
|
24
|
+
// formulation
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
|
|
28
|
+
#include <boost/smart_ptr/detail/sp_obsolete.hpp>
|
|
29
|
+
#include <boost/config.hpp>
|
|
30
|
+
|
|
31
|
+
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
|
|
32
|
+
|
|
33
|
+
#include <boost/config/pragma_message.hpp>
|
|
34
|
+
BOOST_PRAGMA_MESSAGE("Using g++/PowerPC sp_counted_base")
|
|
35
|
+
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
BOOST_SP_OBSOLETE()
|
|
39
|
+
|
|
40
|
+
namespace boost
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
namespace detail
|
|
44
|
+
{
|
|
45
|
+
|
|
46
|
+
inline void atomic_increment( int * pw )
|
|
47
|
+
{
|
|
48
|
+
// ++*pw;
|
|
49
|
+
|
|
50
|
+
int tmp;
|
|
51
|
+
|
|
52
|
+
__asm__
|
|
53
|
+
(
|
|
54
|
+
"0:\n\t"
|
|
55
|
+
"lwarx %1, 0, %2\n\t"
|
|
56
|
+
"addi %1, %1, 1\n\t"
|
|
57
|
+
"stwcx. %1, 0, %2\n\t"
|
|
58
|
+
"bne- 0b":
|
|
59
|
+
|
|
60
|
+
"=m"( *pw ), "=&b"( tmp ):
|
|
61
|
+
"r"( pw ), "m"( *pw ):
|
|
62
|
+
"cc"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
inline int atomic_decrement( int * pw )
|
|
67
|
+
{
|
|
68
|
+
// return --*pw;
|
|
69
|
+
|
|
70
|
+
int rv;
|
|
71
|
+
|
|
72
|
+
__asm__ __volatile__
|
|
73
|
+
(
|
|
74
|
+
"sync\n\t"
|
|
75
|
+
"0:\n\t"
|
|
76
|
+
"lwarx %1, 0, %2\n\t"
|
|
77
|
+
"addi %1, %1, -1\n\t"
|
|
78
|
+
"stwcx. %1, 0, %2\n\t"
|
|
79
|
+
"bne- 0b\n\t"
|
|
80
|
+
"isync":
|
|
81
|
+
|
|
82
|
+
"=m"( *pw ), "=&b"( rv ):
|
|
83
|
+
"r"( pw ), "m"( *pw ):
|
|
84
|
+
"memory", "cc"
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return rv;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
inline int atomic_conditional_increment( int * pw )
|
|
91
|
+
{
|
|
92
|
+
// if( *pw != 0 ) ++*pw;
|
|
93
|
+
// return *pw;
|
|
94
|
+
|
|
95
|
+
int rv;
|
|
96
|
+
|
|
97
|
+
__asm__
|
|
98
|
+
(
|
|
99
|
+
"0:\n\t"
|
|
100
|
+
"lwarx %1, 0, %2\n\t"
|
|
101
|
+
"cmpwi %1, 0\n\t"
|
|
102
|
+
"beq 1f\n\t"
|
|
103
|
+
"addi %1, %1, 1\n\t"
|
|
104
|
+
"1:\n\t"
|
|
105
|
+
"stwcx. %1, 0, %2\n\t"
|
|
106
|
+
"bne- 0b":
|
|
107
|
+
|
|
108
|
+
"=m"( *pw ), "=&b"( rv ):
|
|
109
|
+
"r"( pw ), "m"( *pw ):
|
|
110
|
+
"cc"
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return rv;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
|
117
|
+
{
|
|
118
|
+
private:
|
|
119
|
+
|
|
120
|
+
sp_counted_base( sp_counted_base const & );
|
|
121
|
+
sp_counted_base & operator= ( sp_counted_base const & );
|
|
122
|
+
|
|
123
|
+
int use_count_; // #shared
|
|
124
|
+
int weak_count_; // #weak + (#shared != 0)
|
|
125
|
+
|
|
126
|
+
public:
|
|
127
|
+
|
|
128
|
+
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
|
|
129
|
+
{
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
virtual ~sp_counted_base() // nothrow
|
|
133
|
+
{
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// dispose() is called when use_count_ drops to zero, to release
|
|
137
|
+
// the resources managed by *this.
|
|
138
|
+
|
|
139
|
+
virtual void dispose() = 0; // nothrow
|
|
140
|
+
|
|
141
|
+
// destroy() is called when weak_count_ drops to zero.
|
|
142
|
+
|
|
143
|
+
virtual void destroy() // nothrow
|
|
144
|
+
{
|
|
145
|
+
delete this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
149
|
+
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
|
|
150
|
+
virtual void * get_untyped_deleter() = 0;
|
|
151
|
+
|
|
152
|
+
void add_ref_copy()
|
|
153
|
+
{
|
|
154
|
+
atomic_increment( &use_count_ );
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
bool add_ref_lock() // true on success
|
|
158
|
+
{
|
|
159
|
+
return atomic_conditional_increment( &use_count_ ) != 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
void release() // nothrow
|
|
163
|
+
{
|
|
164
|
+
if( atomic_decrement( &use_count_ ) == 0 )
|
|
165
|
+
{
|
|
166
|
+
dispose();
|
|
167
|
+
weak_release();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
void weak_add_ref() // nothrow
|
|
172
|
+
{
|
|
173
|
+
atomic_increment( &weak_count_ );
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
void weak_release() // nothrow
|
|
177
|
+
{
|
|
178
|
+
if( atomic_decrement( &weak_count_ ) == 0 )
|
|
179
|
+
{
|
|
180
|
+
destroy();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
long use_count() const // nothrow
|
|
185
|
+
{
|
|
186
|
+
return static_cast<int const volatile &>( use_count_ );
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
} // namespace detail
|
|
191
|
+
|
|
192
|
+
} // namespace boost
|
|
193
|
+
|
|
194
|
+
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_PPC_HPP_INCLUDED
|