diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-08-28 15:47:32 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-08-28 15:47:32 +0200 |
commit | 4ecc6555878027f1cc0f853e1aa023f12167f96f (patch) | |
tree | 3c3b5293af846ad4ff9c3176f3594502cc29e3fa /bridges/source/jni_uno | |
parent | 52ffad9bb7be800790de6d918154dbeade88cadd (diff) |
Replace use of oslInterlockedCount with std::atomic in bridges
Change-Id: Iad47a01fd283345a2461eaaea50633bf840e5201
Diffstat (limited to 'bridges/source/jni_uno')
-rw-r--r-- | bridges/source/jni_uno/jni_bridge.cxx | 4 | ||||
-rw-r--r-- | bridges/source/jni_uno/jni_bridge.h | 8 | ||||
-rw-r--r-- | bridges/source/jni_uno/jni_uno2java.cxx | 8 |
3 files changed, 13 insertions, 7 deletions
diff --git a/bridges/source/jni_uno/jni_bridge.cxx b/bridges/source/jni_uno/jni_bridge.cxx index 7926994ebfc2..c8106bb19390 100644 --- a/bridges/source/jni_uno/jni_bridge.cxx +++ b/bridges/source/jni_uno/jni_bridge.cxx @@ -194,7 +194,7 @@ namespace jni_uno void Bridge::acquire() const { - if (osl_atomic_increment( &m_ref ) == 1) + if (++m_ref == 1) { if (m_registered_java2uno) { @@ -216,7 +216,7 @@ void Bridge::acquire() const void Bridge::release() const { - if (! osl_atomic_decrement( &m_ref )) + if (! --m_ref ) { uno_revokeMapping( m_registered_java2uno diff --git a/bridges/source/jni_uno/jni_bridge.h b/bridges/source/jni_uno/jni_bridge.h index 8a216e01c46d..fbf2a8449737 100644 --- a/bridges/source/jni_uno/jni_bridge.h +++ b/bridges/source/jni_uno/jni_bridge.h @@ -20,11 +20,15 @@ #ifndef INCLUDED_BRIDGES_SOURCE_JNI_UNO_JNI_BRIDGE_H #define INCLUDED_BRIDGES_SOURCE_JNI_UNO_JNI_BRIDGE_H +#include <sal/config.h> + +#include <atomic> +#include <cstddef> + #include "jni_base.h" #include "jni_helper.h" #include "osl/diagnose.h" -#include "osl/interlck.h" #include "uno/mapping.h" #include "uno/dispatcher.h" @@ -46,7 +50,7 @@ struct Mapping : public uno_Mapping // Holds environments and mappings: struct Bridge { - mutable oslInterlockedCount m_ref; + mutable std::atomic<std::size_t> m_ref; uno_ExtEnvironment * m_uno_env; uno_Environment * m_java_env; diff --git a/bridges/source/jni_uno/jni_uno2java.cxx b/bridges/source/jni_uno/jni_uno2java.cxx index 58edc8dde002..117a520094fd 100644 --- a/bridges/source/jni_uno/jni_uno2java.cxx +++ b/bridges/source/jni_uno/jni_uno2java.cxx @@ -19,7 +19,9 @@ #include <sal/config.h> +#include <atomic> #include <cassert> +#include <cstddef> #include <memory> #include <sal/alloca.h> @@ -383,7 +385,7 @@ void Bridge::call_java( // an UNO proxy wrapping a Java interface struct UNO_proxy : public uno_Interface { - mutable oslInterlockedCount m_ref; + mutable std::atomic<std::size_t> m_ref; Bridge const * m_bridge; // mapping information @@ -438,7 +440,7 @@ inline UNO_proxy::UNO_proxy( inline void UNO_proxy::acquire() const { - if (osl_atomic_increment( &m_ref ) == 1) + if (++m_ref == 1) { // rebirth of proxy zombie void * that = const_cast< UNO_proxy * >( this ); @@ -454,7 +456,7 @@ inline void UNO_proxy::acquire() const inline void UNO_proxy::release() const { - if (osl_atomic_decrement( &m_ref ) == 0) + if (--m_ref == 0) { // revoke from uno env on last release (*m_bridge->m_uno_env->revokeInterface)( |