@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.
Files changed (289) hide show
  1. package/DittoReactNative.podspec +27 -0
  2. package/README.md +68 -51
  3. package/node/ditto.cjs.js +1639 -851
  4. package/node/ditto.darwin-arm64.node +0 -0
  5. package/node/ditto.darwin-x64.node +0 -0
  6. package/node/ditto.linux-arm.node +0 -0
  7. package/node/ditto.linux-x64.node +0 -0
  8. package/node/ditto.win32-x64.node +0 -0
  9. package/node/transports.darwin-arm64.node +0 -0
  10. package/node/transports.darwin-x64.node +0 -0
  11. package/package.json +34 -38
  12. package/react-native/android/CMakeLists.txt +37 -0
  13. package/react-native/android/build.gradle +203 -0
  14. package/react-native/android/cpp-adapter.cpp +254 -0
  15. package/react-native/android/gradle.properties +5 -0
  16. package/react-native/android/src/main/AndroidManifest.xml +4 -0
  17. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +85 -0
  18. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
  19. package/react-native/boost/boost/assert.hpp +85 -0
  20. package/react-native/boost/boost/config/abi/borland_prefix.hpp +27 -0
  21. package/react-native/boost/boost/config/abi/borland_suffix.hpp +12 -0
  22. package/react-native/boost/boost/config/abi/msvc_prefix.hpp +22 -0
  23. package/react-native/boost/boost/config/abi/msvc_suffix.hpp +8 -0
  24. package/react-native/boost/boost/config/abi_prefix.hpp +25 -0
  25. package/react-native/boost/boost/config/abi_suffix.hpp +25 -0
  26. package/react-native/boost/boost/config/assert_cxx03.hpp +211 -0
  27. package/react-native/boost/boost/config/assert_cxx11.hpp +209 -0
  28. package/react-native/boost/boost/config/assert_cxx14.hpp +47 -0
  29. package/react-native/boost/boost/config/assert_cxx17.hpp +62 -0
  30. package/react-native/boost/boost/config/assert_cxx20.hpp +59 -0
  31. package/react-native/boost/boost/config/assert_cxx98.hpp +23 -0
  32. package/react-native/boost/boost/config/auto_link.hpp +525 -0
  33. package/react-native/boost/boost/config/compiler/borland.hpp +339 -0
  34. package/react-native/boost/boost/config/compiler/clang.hpp +366 -0
  35. package/react-native/boost/boost/config/compiler/clang_version.hpp +83 -0
  36. package/react-native/boost/boost/config/compiler/codegear.hpp +385 -0
  37. package/react-native/boost/boost/config/compiler/comeau.hpp +59 -0
  38. package/react-native/boost/boost/config/compiler/common_edg.hpp +183 -0
  39. package/react-native/boost/boost/config/compiler/compaq_cxx.hpp +19 -0
  40. package/react-native/boost/boost/config/compiler/cray.hpp +446 -0
  41. package/react-native/boost/boost/config/compiler/diab.hpp +26 -0
  42. package/react-native/boost/boost/config/compiler/digitalmars.hpp +143 -0
  43. package/react-native/boost/boost/config/compiler/gcc.hpp +383 -0
  44. package/react-native/boost/boost/config/compiler/gcc_xml.hpp +114 -0
  45. package/react-native/boost/boost/config/compiler/greenhills.hpp +28 -0
  46. package/react-native/boost/boost/config/compiler/hp_acc.hpp +149 -0
  47. package/react-native/boost/boost/config/compiler/intel.hpp +577 -0
  48. package/react-native/boost/boost/config/compiler/kai.hpp +33 -0
  49. package/react-native/boost/boost/config/compiler/metrowerks.hpp +198 -0
  50. package/react-native/boost/boost/config/compiler/mpw.hpp +140 -0
  51. package/react-native/boost/boost/config/compiler/nvcc.hpp +61 -0
  52. package/react-native/boost/boost/config/compiler/pathscale.hpp +138 -0
  53. package/react-native/boost/boost/config/compiler/pgi.hpp +23 -0
  54. package/react-native/boost/boost/config/compiler/sgi_mipspro.hpp +29 -0
  55. package/react-native/boost/boost/config/compiler/sunpro_cc.hpp +222 -0
  56. package/react-native/boost/boost/config/compiler/vacpp.hpp +186 -0
  57. package/react-native/boost/boost/config/compiler/visualc.hpp +391 -0
  58. package/react-native/boost/boost/config/compiler/xlcpp.hpp +299 -0
  59. package/react-native/boost/boost/config/compiler/xlcpp_zos.hpp +173 -0
  60. package/react-native/boost/boost/config/detail/cxx_composite.hpp +203 -0
  61. package/react-native/boost/boost/config/detail/posix_features.hpp +95 -0
  62. package/react-native/boost/boost/config/detail/select_compiler_config.hpp +157 -0
  63. package/react-native/boost/boost/config/detail/select_platform_config.hpp +147 -0
  64. package/react-native/boost/boost/config/detail/select_stdlib_config.hpp +121 -0
  65. package/react-native/boost/boost/config/detail/suffix.hpp +1294 -0
  66. package/react-native/boost/boost/config/header_deprecated.hpp +26 -0
  67. package/react-native/boost/boost/config/helper_macros.hpp +37 -0
  68. package/react-native/boost/boost/config/no_tr1/cmath.hpp +28 -0
  69. package/react-native/boost/boost/config/no_tr1/complex.hpp +28 -0
  70. package/react-native/boost/boost/config/no_tr1/functional.hpp +28 -0
  71. package/react-native/boost/boost/config/no_tr1/memory.hpp +28 -0
  72. package/react-native/boost/boost/config/no_tr1/utility.hpp +28 -0
  73. package/react-native/boost/boost/config/platform/aix.hpp +33 -0
  74. package/react-native/boost/boost/config/platform/amigaos.hpp +15 -0
  75. package/react-native/boost/boost/config/platform/beos.hpp +26 -0
  76. package/react-native/boost/boost/config/platform/bsd.hpp +83 -0
  77. package/react-native/boost/boost/config/platform/cloudabi.hpp +18 -0
  78. package/react-native/boost/boost/config/platform/cray.hpp +18 -0
  79. package/react-native/boost/boost/config/platform/cygwin.hpp +71 -0
  80. package/react-native/boost/boost/config/platform/haiku.hpp +31 -0
  81. package/react-native/boost/boost/config/platform/hpux.hpp +87 -0
  82. package/react-native/boost/boost/config/platform/irix.hpp +31 -0
  83. package/react-native/boost/boost/config/platform/linux.hpp +106 -0
  84. package/react-native/boost/boost/config/platform/macos.hpp +87 -0
  85. package/react-native/boost/boost/config/platform/qnxnto.hpp +31 -0
  86. package/react-native/boost/boost/config/platform/solaris.hpp +31 -0
  87. package/react-native/boost/boost/config/platform/symbian.hpp +97 -0
  88. package/react-native/boost/boost/config/platform/vms.hpp +25 -0
  89. package/react-native/boost/boost/config/platform/vxworks.hpp +422 -0
  90. package/react-native/boost/boost/config/platform/wasm.hpp +23 -0
  91. package/react-native/boost/boost/config/platform/win32.hpp +90 -0
  92. package/react-native/boost/boost/config/platform/zos.hpp +32 -0
  93. package/react-native/boost/boost/config/pragma_message.hpp +31 -0
  94. package/react-native/boost/boost/config/requires_threads.hpp +92 -0
  95. package/react-native/boost/boost/config/stdlib/dinkumware.hpp +324 -0
  96. package/react-native/boost/boost/config/stdlib/libcomo.hpp +93 -0
  97. package/react-native/boost/boost/config/stdlib/libcpp.hpp +180 -0
  98. package/react-native/boost/boost/config/stdlib/libstdcpp3.hpp +482 -0
  99. package/react-native/boost/boost/config/stdlib/modena.hpp +79 -0
  100. package/react-native/boost/boost/config/stdlib/msl.hpp +98 -0
  101. package/react-native/boost/boost/config/stdlib/roguewave.hpp +208 -0
  102. package/react-native/boost/boost/config/stdlib/sgi.hpp +168 -0
  103. package/react-native/boost/boost/config/stdlib/stlport.hpp +258 -0
  104. package/react-native/boost/boost/config/stdlib/vacpp.hpp +74 -0
  105. package/react-native/boost/boost/config/stdlib/xlcpp_zos.hpp +61 -0
  106. package/react-native/boost/boost/config/user.hpp +133 -0
  107. package/react-native/boost/boost/config/warning_disable.hpp +47 -0
  108. package/react-native/boost/boost/config/workaround.hpp +305 -0
  109. package/react-native/boost/boost/config.hpp +67 -0
  110. package/react-native/boost/boost/cstdint.hpp +556 -0
  111. package/react-native/boost/boost/intrusive_ptr.hpp +18 -0
  112. package/react-native/boost/boost/smart_ptr/detail/atomic_count.hpp +103 -0
  113. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc.hpp +79 -0
  114. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp +63 -0
  115. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +88 -0
  116. package/react-native/boost/boost/smart_ptr/detail/atomic_count_nt.hpp +66 -0
  117. package/react-native/boost/boost/smart_ptr/detail/atomic_count_pt.hpp +104 -0
  118. package/react-native/boost/boost/smart_ptr/detail/atomic_count_spin.hpp +69 -0
  119. package/react-native/boost/boost/smart_ptr/detail/atomic_count_std_atomic.hpp +67 -0
  120. package/react-native/boost/boost/smart_ptr/detail/atomic_count_sync.hpp +72 -0
  121. package/react-native/boost/boost/smart_ptr/detail/atomic_count_win32.hpp +70 -0
  122. package/react-native/boost/boost/smart_ptr/detail/local_counted_base.hpp +148 -0
  123. package/react-native/boost/boost/smart_ptr/detail/local_sp_deleter.hpp +91 -0
  124. package/react-native/boost/boost/smart_ptr/detail/operator_bool.hpp +64 -0
  125. package/react-native/boost/boost/smart_ptr/detail/requires_cxx11.hpp +23 -0
  126. package/react-native/boost/boost/smart_ptr/detail/shared_count.hpp +707 -0
  127. package/react-native/boost/boost/smart_ptr/detail/sp_convertible.hpp +92 -0
  128. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base.hpp +92 -0
  129. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +163 -0
  130. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_aix.hpp +152 -0
  131. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +185 -0
  132. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp +148 -0
  133. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +170 -0
  134. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +200 -0
  135. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +194 -0
  136. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +179 -0
  137. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +186 -0
  138. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_nt.hpp +119 -0
  139. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_pt.hpp +147 -0
  140. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +174 -0
  141. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_spin.hpp +141 -0
  142. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +147 -0
  143. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp +165 -0
  144. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +163 -0
  145. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_w32.hpp +140 -0
  146. package/react-native/boost/boost/smart_ptr/detail/sp_counted_impl.hpp +309 -0
  147. package/react-native/boost/boost/smart_ptr/detail/sp_disable_deprecated.hpp +40 -0
  148. package/react-native/boost/boost/smart_ptr/detail/sp_forward.hpp +52 -0
  149. package/react-native/boost/boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp +27 -0
  150. package/react-native/boost/boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp +69 -0
  151. package/react-native/boost/boost/smart_ptr/detail/sp_interlocked.hpp +173 -0
  152. package/react-native/boost/boost/smart_ptr/detail/sp_noexcept.hpp +48 -0
  153. package/react-native/boost/boost/smart_ptr/detail/sp_nullptr_t.hpp +45 -0
  154. package/react-native/boost/boost/smart_ptr/detail/sp_obsolete.hpp +32 -0
  155. package/react-native/boost/boost/smart_ptr/detail/sp_thread_pause.hpp +51 -0
  156. package/react-native/boost/boost/smart_ptr/detail/sp_thread_sleep.hpp +104 -0
  157. package/react-native/boost/boost/smart_ptr/detail/sp_thread_yield.hpp +100 -0
  158. package/react-native/boost/boost/smart_ptr/detail/sp_typeinfo_.hpp +58 -0
  159. package/react-native/boost/boost/smart_ptr/detail/sp_win32_sleep.hpp +49 -0
  160. package/react-native/boost/boost/smart_ptr/intrusive_ptr.hpp +409 -0
  161. package/react-native/boost/boost/smart_ptr/intrusive_ref_counter.hpp +188 -0
  162. package/react-native/cpp/include/Attachment.h +16 -0
  163. package/react-native/cpp/include/Authentication.h +23 -0
  164. package/react-native/cpp/include/Collection.h +13 -0
  165. package/react-native/cpp/include/DQL.h +21 -0
  166. package/react-native/cpp/include/Document.h +17 -0
  167. package/react-native/cpp/include/Identity.h +17 -0
  168. package/react-native/cpp/include/Lifecycle.h +16 -0
  169. package/react-native/cpp/include/LiveQuery.h +17 -0
  170. package/react-native/cpp/include/Logger.h +22 -0
  171. package/react-native/cpp/include/Misc.h +26 -0
  172. package/react-native/cpp/include/Presence.h +14 -0
  173. package/react-native/cpp/include/RetainableState.h +24 -0
  174. package/react-native/cpp/include/SmallPeerInfo.h +17 -0
  175. package/react-native/cpp/include/Transports.h +25 -0
  176. package/react-native/cpp/include/TypedArray.hpp +167 -0
  177. package/react-native/cpp/include/Utils.h +61 -0
  178. package/react-native/cpp/include/main.h +10 -0
  179. package/react-native/cpp/src/Attachment.cpp +86 -0
  180. package/react-native/cpp/src/Authentication.cpp +224 -0
  181. package/react-native/cpp/src/Collection.cpp +54 -0
  182. package/react-native/cpp/src/DQL.cpp +254 -0
  183. package/react-native/cpp/src/Document.cpp +146 -0
  184. package/react-native/cpp/src/Identity.cpp +123 -0
  185. package/react-native/cpp/src/Lifecycle.cpp +75 -0
  186. package/react-native/cpp/src/LiveQuery.cpp +64 -0
  187. package/react-native/cpp/src/Logger.cpp +200 -0
  188. package/react-native/cpp/src/Misc.cpp +271 -0
  189. package/react-native/cpp/src/Presence.cpp +77 -0
  190. package/react-native/cpp/src/RetainableState.cpp +15 -0
  191. package/react-native/cpp/src/SmallPeerInfo.cpp +108 -0
  192. package/react-native/cpp/src/Transports.cpp +270 -0
  193. package/react-native/cpp/src/TypedArray.cpp +303 -0
  194. package/react-native/cpp/src/Utils.cpp +138 -0
  195. package/react-native/cpp/src/main.cpp +149 -0
  196. package/react-native/dittoffi/dittoffi.h +4698 -0
  197. package/react-native/dittoffi/ifaddrs.cpp +385 -0
  198. package/react-native/dittoffi/ifaddrs.h +206 -0
  199. package/react-native/ios/DittoRNSDK.h +7 -0
  200. package/react-native/ios/DittoRNSDK.mm +107 -0
  201. package/react-native/ios/YeetJSIUtils.h +60 -0
  202. package/react-native/ios/YeetJSIUtils.mm +196 -0
  203. package/react-native/lib/commonjs/ditto.rn.js +93 -0
  204. package/react-native/lib/commonjs/ditto.rn.js.map +1 -0
  205. package/react-native/lib/commonjs/index.js +14 -0
  206. package/react-native/lib/commonjs/index.js.map +1 -0
  207. package/react-native/lib/module/ditto.rn.js +83 -0
  208. package/react-native/lib/module/ditto.rn.js.map +1 -0
  209. package/react-native/lib/module/index.js +13 -0
  210. package/react-native/lib/module/index.js.map +1 -0
  211. package/react-native/lib/typescript/ditto.rn.d.ts +15 -0
  212. package/react-native/lib/typescript/ditto.rn.d.ts.map +1 -0
  213. package/react-native/lib/typescript/index.d.ts +1 -0
  214. package/react-native/lib/typescript/index.d.ts.map +1 -0
  215. package/react-native/scripts/ruby/include_local_boost.rb +78 -0
  216. package/react-native/src/ditto.rn.ts +91 -0
  217. package/react-native/src/environment/environment.fallback.ts +4 -0
  218. package/react-native/src/index.ts +26 -0
  219. package/react-native/src/sources/@cbor-redux.ts +2 -0
  220. package/react-native/src/sources/@ditto.core.ts +1 -0
  221. package/react-native/src/sources/@environment.ts +2 -0
  222. package/react-native/src/sources/attachment-fetch-event.ts +54 -0
  223. package/react-native/src/sources/attachment-fetcher-manager.ts +129 -0
  224. package/react-native/src/sources/attachment-fetcher.ts +124 -0
  225. package/react-native/src/sources/attachment-token.ts +48 -0
  226. package/react-native/src/sources/attachment.ts +59 -0
  227. package/react-native/src/sources/augment.ts +89 -0
  228. package/react-native/src/sources/authenticator.ts +314 -0
  229. package/react-native/src/sources/base-pending-cursor-operation.ts +237 -0
  230. package/react-native/src/sources/base-pending-id-specific-operation.ts +109 -0
  231. package/react-native/src/sources/bridge.ts +549 -0
  232. package/react-native/src/sources/build-time-constants.ts +4 -0
  233. package/react-native/src/sources/cbor.ts +35 -0
  234. package/react-native/src/sources/collection-interface.ts +67 -0
  235. package/react-native/src/sources/collection.ts +212 -0
  236. package/react-native/src/sources/collections-event.ts +99 -0
  237. package/react-native/src/sources/counter.ts +77 -0
  238. package/react-native/src/sources/ditto.ts +945 -0
  239. package/react-native/src/sources/document-id.ts +159 -0
  240. package/react-native/src/sources/document-path.ts +303 -0
  241. package/react-native/src/sources/document.ts +192 -0
  242. package/react-native/src/sources/epilogue.ts +24 -0
  243. package/react-native/src/sources/error-codes.ts +52 -0
  244. package/react-native/src/sources/error.ts +203 -0
  245. package/react-native/src/sources/essentials.ts +53 -0
  246. package/react-native/src/sources/ffi-error.ts +117 -0
  247. package/react-native/src/sources/ffi.ts +1972 -0
  248. package/react-native/src/sources/identity.ts +163 -0
  249. package/react-native/src/sources/init.ts +70 -0
  250. package/react-native/src/sources/internal.ts +113 -0
  251. package/react-native/src/sources/keep-alive.ts +69 -0
  252. package/react-native/src/sources/key-path.ts +195 -0
  253. package/react-native/src/sources/live-query-event.ts +208 -0
  254. package/react-native/src/sources/live-query-manager.ts +101 -0
  255. package/react-native/src/sources/live-query.ts +164 -0
  256. package/react-native/src/sources/logger.ts +196 -0
  257. package/react-native/src/sources/observer-manager.ts +175 -0
  258. package/react-native/src/sources/observer.ts +77 -0
  259. package/react-native/src/sources/pending-collections-operation.ts +232 -0
  260. package/react-native/src/sources/pending-cursor-operation.ts +218 -0
  261. package/react-native/src/sources/pending-id-specific-operation.ts +216 -0
  262. package/react-native/src/sources/presence-manager.ts +160 -0
  263. package/react-native/src/sources/presence.ts +238 -0
  264. package/react-native/src/sources/query-result-item.ts +116 -0
  265. package/react-native/src/sources/query-result.ts +55 -0
  266. package/react-native/src/sources/register.ts +92 -0
  267. package/react-native/src/sources/small-peer-info.ts +176 -0
  268. package/react-native/src/sources/static-tcp-client.ts +6 -0
  269. package/react-native/src/sources/store-observer.ts +176 -0
  270. package/react-native/src/sources/store.ts +365 -0
  271. package/react-native/src/sources/subscription-manager.ts +98 -0
  272. package/react-native/src/sources/subscription.ts +88 -0
  273. package/react-native/src/sources/sync-subscription.ts +90 -0
  274. package/react-native/src/sources/sync.ts +495 -0
  275. package/react-native/src/sources/test-helpers.ts +24 -0
  276. package/react-native/src/sources/transport-conditions-manager.ts +104 -0
  277. package/react-native/src/sources/transport-config.ts +428 -0
  278. package/react-native/src/sources/update-result.ts +66 -0
  279. package/react-native/src/sources/update-results-map.ts +57 -0
  280. package/react-native/src/sources/websocket-client.ts +6 -0
  281. package/react-native/src/sources/write-transaction-collection.ts +122 -0
  282. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +101 -0
  283. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +72 -0
  284. package/react-native/src/sources/write-transaction.ts +119 -0
  285. package/react-native.config.js +9 -0
  286. package/types/ditto.d.ts +1230 -798
  287. package/web/ditto.es6.js +1 -1
  288. package/web/ditto.umd.js +1 -1
  289. package/web/ditto.wasm +0 -0
@@ -0,0 +1,179 @@
1
+ #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED
2
+ #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_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_sparc.hpp - g++ on Sparc V8+
11
+ //
12
+ // Copyright (c) 2006 Piotr Wyderski
13
+ // Copyright (c) 2006 Tomas Puverle
14
+ // Copyright (c) 2006 Peter Dimov
15
+ //
16
+ // Distributed under the Boost Software License, Version 1.0.
17
+ // See accompanying file LICENSE_1_0.txt or copy at
18
+ // http://www.boost.org/LICENSE_1_0.txt
19
+ //
20
+ // Thanks to Michael van der Westhuizen
21
+
22
+ #include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
23
+ #include <boost/smart_ptr/detail/sp_obsolete.hpp>
24
+ #include <boost/config.hpp>
25
+ #include <inttypes.h> // int32_t
26
+
27
+ #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
28
+
29
+ #include <boost/config/pragma_message.hpp>
30
+ BOOST_PRAGMA_MESSAGE("Using g++/Sparc sp_counted_base")
31
+
32
+ #endif
33
+
34
+ BOOST_SP_OBSOLETE()
35
+
36
+ namespace boost
37
+ {
38
+
39
+ namespace detail
40
+ {
41
+
42
+ inline int32_t compare_and_swap( int32_t * dest_, int32_t compare_, int32_t swap_ )
43
+ {
44
+ __asm__ __volatile__( "cas [%1], %2, %0"
45
+ : "+r" (swap_)
46
+ : "r" (dest_), "r" (compare_)
47
+ : "memory" );
48
+
49
+ return swap_;
50
+ }
51
+
52
+ inline int32_t atomic_fetch_and_add( int32_t * pw, int32_t dv )
53
+ {
54
+ // long r = *pw;
55
+ // *pw += dv;
56
+ // return r;
57
+
58
+ for( ;; )
59
+ {
60
+ int32_t r = *pw;
61
+
62
+ if( __builtin_expect((compare_and_swap(pw, r, r + dv) == r), 1) )
63
+ {
64
+ return r;
65
+ }
66
+ }
67
+ }
68
+
69
+ inline void atomic_increment( int32_t * pw )
70
+ {
71
+ atomic_fetch_and_add( pw, 1 );
72
+ }
73
+
74
+ inline int32_t atomic_decrement( int32_t * pw )
75
+ {
76
+ return atomic_fetch_and_add( pw, -1 );
77
+ }
78
+
79
+ inline int32_t atomic_conditional_increment( int32_t * pw )
80
+ {
81
+ // long r = *pw;
82
+ // if( r != 0 ) ++*pw;
83
+ // return r;
84
+
85
+ for( ;; )
86
+ {
87
+ int32_t r = *pw;
88
+
89
+ if( r == 0 )
90
+ {
91
+ return r;
92
+ }
93
+
94
+ if( __builtin_expect( ( compare_and_swap( pw, r, r + 1 ) == r ), 1 ) )
95
+ {
96
+ return r;
97
+ }
98
+ }
99
+ }
100
+
101
+ class BOOST_SYMBOL_VISIBLE sp_counted_base
102
+ {
103
+ private:
104
+
105
+ sp_counted_base( sp_counted_base const & );
106
+ sp_counted_base & operator= ( sp_counted_base const & );
107
+
108
+ int32_t use_count_; // #shared
109
+ int32_t weak_count_; // #weak + (#shared != 0)
110
+
111
+ public:
112
+
113
+ sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
114
+ {
115
+ }
116
+
117
+ virtual ~sp_counted_base() // nothrow
118
+ {
119
+ }
120
+
121
+ // dispose() is called when use_count_ drops to zero, to release
122
+ // the resources managed by *this.
123
+
124
+ virtual void dispose() = 0; // nothrow
125
+
126
+ // destroy() is called when weak_count_ drops to zero.
127
+
128
+ virtual void destroy() // nothrow
129
+ {
130
+ delete this;
131
+ }
132
+
133
+ virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
134
+ virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
135
+ virtual void * get_untyped_deleter() = 0;
136
+
137
+ void add_ref_copy()
138
+ {
139
+ atomic_increment( &use_count_ );
140
+ }
141
+
142
+ bool add_ref_lock() // true on success
143
+ {
144
+ return atomic_conditional_increment( &use_count_ ) != 0;
145
+ }
146
+
147
+ void release() // nothrow
148
+ {
149
+ if( atomic_decrement( &use_count_ ) == 1 )
150
+ {
151
+ dispose();
152
+ weak_release();
153
+ }
154
+ }
155
+
156
+ void weak_add_ref() // nothrow
157
+ {
158
+ atomic_increment( &weak_count_ );
159
+ }
160
+
161
+ void weak_release() // nothrow
162
+ {
163
+ if( atomic_decrement( &weak_count_ ) == 1 )
164
+ {
165
+ destroy();
166
+ }
167
+ }
168
+
169
+ long use_count() const // nothrow
170
+ {
171
+ return const_cast< int32_t const volatile & >( use_count_ );
172
+ }
173
+ };
174
+
175
+ } // namespace detail
176
+
177
+ } // namespace boost
178
+
179
+ #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_SPARC_HPP_INCLUDED
@@ -0,0 +1,186 @@
1
+ #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED
2
+ #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_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_x86.hpp - g++ on 486+ or AMD64
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++/x86 sp_counted_base")
35
+
36
+ #endif
37
+
38
+ BOOST_SP_OBSOLETE()
39
+
40
+ namespace boost
41
+ {
42
+
43
+ namespace detail
44
+ {
45
+
46
+ inline int atomic_exchange_and_add( int * pw, int dv )
47
+ {
48
+ // int r = *pw;
49
+ // *pw += dv;
50
+ // return r;
51
+
52
+ int r;
53
+
54
+ __asm__ __volatile__
55
+ (
56
+ "lock\n\t"
57
+ "xadd %1, %0":
58
+ "=m"( *pw ), "=r"( r ): // outputs (%0, %1)
59
+ "m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1)
60
+ "memory", "cc" // clobbers
61
+ );
62
+
63
+ return r;
64
+ }
65
+
66
+ inline void atomic_increment( int * pw )
67
+ {
68
+ //atomic_exchange_and_add( pw, 1 );
69
+
70
+ __asm__
71
+ (
72
+ "lock\n\t"
73
+ "incl %0":
74
+ "=m"( *pw ): // output (%0)
75
+ "m"( *pw ): // input (%1)
76
+ "cc" // clobbers
77
+ );
78
+ }
79
+
80
+ inline int atomic_conditional_increment( int * pw )
81
+ {
82
+ // int rv = *pw;
83
+ // if( rv != 0 ) ++*pw;
84
+ // return rv;
85
+
86
+ int rv, tmp;
87
+
88
+ __asm__
89
+ (
90
+ "movl %0, %%eax\n\t"
91
+ "0:\n\t"
92
+ "test %%eax, %%eax\n\t"
93
+ "je 1f\n\t"
94
+ "movl %%eax, %2\n\t"
95
+ "incl %2\n\t"
96
+ "lock\n\t"
97
+ "cmpxchgl %2, %0\n\t"
98
+ "jne 0b\n\t"
99
+ "1:":
100
+ "=m"( *pw ), "=&a"( rv ), "=&r"( tmp ): // outputs (%0, %1, %2)
101
+ "m"( *pw ): // input (%3)
102
+ "cc" // clobbers
103
+ );
104
+
105
+ return rv;
106
+ }
107
+
108
+ class BOOST_SYMBOL_VISIBLE sp_counted_base
109
+ {
110
+ private:
111
+
112
+ sp_counted_base( sp_counted_base const & );
113
+ sp_counted_base & operator= ( sp_counted_base const & );
114
+
115
+ int use_count_; // #shared
116
+ int weak_count_; // #weak + (#shared != 0)
117
+
118
+ public:
119
+
120
+ sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
121
+ {
122
+ }
123
+
124
+ virtual ~sp_counted_base() // nothrow
125
+ {
126
+ }
127
+
128
+ // dispose() is called when use_count_ drops to zero, to release
129
+ // the resources managed by *this.
130
+
131
+ virtual void dispose() = 0; // nothrow
132
+
133
+ // destroy() is called when weak_count_ drops to zero.
134
+
135
+ virtual void destroy() // nothrow
136
+ {
137
+ delete this;
138
+ }
139
+
140
+ virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
141
+ virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
142
+ virtual void * get_untyped_deleter() = 0;
143
+
144
+ void add_ref_copy()
145
+ {
146
+ atomic_increment( &use_count_ );
147
+ }
148
+
149
+ bool add_ref_lock() // true on success
150
+ {
151
+ return atomic_conditional_increment( &use_count_ ) != 0;
152
+ }
153
+
154
+ void release() // nothrow
155
+ {
156
+ if( atomic_exchange_and_add( &use_count_, -1 ) == 1 )
157
+ {
158
+ dispose();
159
+ weak_release();
160
+ }
161
+ }
162
+
163
+ void weak_add_ref() // nothrow
164
+ {
165
+ atomic_increment( &weak_count_ );
166
+ }
167
+
168
+ void weak_release() // nothrow
169
+ {
170
+ if( atomic_exchange_and_add( &weak_count_, -1 ) == 1 )
171
+ {
172
+ destroy();
173
+ }
174
+ }
175
+
176
+ long use_count() const // nothrow
177
+ {
178
+ return static_cast<int const volatile &>( use_count_ );
179
+ }
180
+ };
181
+
182
+ } // namespace detail
183
+
184
+ } // namespace boost
185
+
186
+ #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_GCC_X86_HPP_INCLUDED
@@ -0,0 +1,119 @@
1
+ #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
2
+ #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_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_nt.hpp
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
+ #include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
22
+ #include <boost/smart_ptr/detail/sp_noexcept.hpp>
23
+ #include <boost/config.hpp>
24
+ #include <boost/cstdint.hpp>
25
+
26
+ #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
27
+
28
+ #include <boost/config/pragma_message.hpp>
29
+ BOOST_PRAGMA_MESSAGE("Using single-threaded, non-atomic sp_counted_base")
30
+
31
+ #endif
32
+
33
+ namespace boost
34
+ {
35
+
36
+ namespace detail
37
+ {
38
+
39
+ class BOOST_SYMBOL_VISIBLE sp_counted_base
40
+ {
41
+ private:
42
+
43
+ sp_counted_base( sp_counted_base const & );
44
+ sp_counted_base & operator= ( sp_counted_base const & );
45
+
46
+ boost::int_least32_t use_count_; // #shared
47
+ boost::int_least32_t weak_count_; // #weak + (#shared != 0)
48
+
49
+ public:
50
+
51
+ sp_counted_base() BOOST_SP_NOEXCEPT: use_count_( 1 ), weak_count_( 1 )
52
+ {
53
+ }
54
+
55
+ virtual ~sp_counted_base() /*BOOST_SP_NOEXCEPT*/
56
+ {
57
+ }
58
+
59
+ // dispose() is called when use_count_ drops to zero, to release
60
+ // the resources managed by *this.
61
+
62
+ virtual void dispose() BOOST_SP_NOEXCEPT = 0; // nothrow
63
+
64
+ // destroy() is called when weak_count_ drops to zero.
65
+
66
+ virtual void destroy() BOOST_SP_NOEXCEPT // nothrow
67
+ {
68
+ delete this;
69
+ }
70
+
71
+ virtual void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
72
+ virtual void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
73
+ virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT = 0;
74
+
75
+ void add_ref_copy() BOOST_SP_NOEXCEPT
76
+ {
77
+ ++use_count_;
78
+ }
79
+
80
+ bool add_ref_lock() BOOST_SP_NOEXCEPT // true on success
81
+ {
82
+ if( use_count_ == 0 ) return false;
83
+ ++use_count_;
84
+ return true;
85
+ }
86
+
87
+ void release() BOOST_SP_NOEXCEPT
88
+ {
89
+ if( --use_count_ == 0 )
90
+ {
91
+ dispose();
92
+ weak_release();
93
+ }
94
+ }
95
+
96
+ void weak_add_ref() BOOST_SP_NOEXCEPT
97
+ {
98
+ ++weak_count_;
99
+ }
100
+
101
+ void weak_release() BOOST_SP_NOEXCEPT
102
+ {
103
+ if( --weak_count_ == 0 )
104
+ {
105
+ destroy();
106
+ }
107
+ }
108
+
109
+ long use_count() const BOOST_SP_NOEXCEPT
110
+ {
111
+ return use_count_;
112
+ }
113
+ };
114
+
115
+ } // namespace detail
116
+
117
+ } // namespace boost
118
+
119
+ #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_NT_HPP_INCLUDED
@@ -0,0 +1,147 @@
1
+ #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED
2
+ #define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_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_pt.hpp
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
+ #include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
22
+ #include <boost/assert.hpp>
23
+ #include <boost/config.hpp>
24
+ #include <boost/cstdint.hpp>
25
+ #include <pthread.h>
26
+
27
+ #if defined(BOOST_SP_REPORT_IMPLEMENTATION)
28
+
29
+ #include <boost/config/pragma_message.hpp>
30
+ BOOST_PRAGMA_MESSAGE("Using pthread_mutex sp_counted_base")
31
+
32
+ #endif
33
+
34
+ namespace boost
35
+ {
36
+
37
+ namespace detail
38
+ {
39
+
40
+ class BOOST_SYMBOL_VISIBLE sp_counted_base
41
+ {
42
+ private:
43
+
44
+ sp_counted_base( sp_counted_base const & );
45
+ sp_counted_base & operator= ( sp_counted_base const & );
46
+
47
+ boost::int_least32_t use_count_; // #shared
48
+ boost::int_least32_t weak_count_; // #weak + (#shared != 0)
49
+
50
+ mutable pthread_mutex_t m_;
51
+
52
+ public:
53
+
54
+ sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
55
+ {
56
+ // HPUX 10.20 / DCE has a nonstandard pthread_mutex_init
57
+
58
+ #if defined(__hpux) && defined(_DECTHREADS_)
59
+ BOOST_VERIFY( pthread_mutex_init( &m_, pthread_mutexattr_default ) == 0 );
60
+ #else
61
+ BOOST_VERIFY( pthread_mutex_init( &m_, 0 ) == 0 );
62
+ #endif
63
+ }
64
+
65
+ virtual ~sp_counted_base() // nothrow
66
+ {
67
+ BOOST_VERIFY( pthread_mutex_destroy( &m_ ) == 0 );
68
+ }
69
+
70
+ // dispose() is called when use_count_ drops to zero, to release
71
+ // the resources managed by *this.
72
+
73
+ virtual void dispose() = 0; // nothrow
74
+
75
+ // destroy() is called when weak_count_ drops to zero.
76
+
77
+ virtual void destroy() // nothrow
78
+ {
79
+ delete this;
80
+ }
81
+
82
+ virtual void * get_deleter( sp_typeinfo_ const & ti ) = 0;
83
+ virtual void * get_local_deleter( sp_typeinfo_ const & ti ) = 0;
84
+ virtual void * get_untyped_deleter() = 0;
85
+
86
+ void add_ref_copy()
87
+ {
88
+ BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
89
+ ++use_count_;
90
+ BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
91
+ }
92
+
93
+ bool add_ref_lock() // true on success
94
+ {
95
+ BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
96
+ bool r = use_count_ == 0? false: ( ++use_count_, true );
97
+ BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
98
+ return r;
99
+ }
100
+
101
+ void release() // nothrow
102
+ {
103
+ BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
104
+ boost::int_least32_t new_use_count = --use_count_;
105
+ BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
106
+
107
+ if( new_use_count == 0 )
108
+ {
109
+ dispose();
110
+ weak_release();
111
+ }
112
+ }
113
+
114
+ void weak_add_ref() // nothrow
115
+ {
116
+ BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
117
+ ++weak_count_;
118
+ BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
119
+ }
120
+
121
+ void weak_release() // nothrow
122
+ {
123
+ BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
124
+ boost::int_least32_t new_weak_count = --weak_count_;
125
+ BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
126
+
127
+ if( new_weak_count == 0 )
128
+ {
129
+ destroy();
130
+ }
131
+ }
132
+
133
+ long use_count() const // nothrow
134
+ {
135
+ BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
136
+ boost::int_least32_t r = use_count_;
137
+ BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
138
+
139
+ return r;
140
+ }
141
+ };
142
+
143
+ } // namespace detail
144
+
145
+ } // namespace boost
146
+
147
+ #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_PT_HPP_INCLUDED