summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-08-28 15:47:32 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-08-28 15:47:32 +0200
commit4ecc6555878027f1cc0f853e1aa023f12167f96f (patch)
tree3c3b5293af846ad4ff9c3176f3594502cc29e3fa /bridges
parent52ffad9bb7be800790de6d918154dbeade88cadd (diff)
Replace use of oslInterlockedCount with std::atomic in bridges
Change-Id: Iad47a01fd283345a2461eaaea50633bf840e5201
Diffstat (limited to 'bridges')
-rw-r--r--bridges/inc/bridge.hxx8
-rw-r--r--bridges/inc/cppinterfaceproxy.hxx8
-rw-r--r--bridges/inc/unointerfaceproxy.hxx8
-rw-r--r--bridges/source/cpp_uno/shared/bridge.cxx5
-rw-r--r--bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx5
-rw-r--r--bridges/source/cpp_uno/shared/unointerfaceproxy.cxx7
-rw-r--r--bridges/source/jni_uno/jni_bridge.cxx4
-rw-r--r--bridges/source/jni_uno/jni_bridge.h8
-rw-r--r--bridges/source/jni_uno/jni_uno2java.cxx8
9 files changed, 37 insertions, 24 deletions
diff --git a/bridges/inc/bridge.hxx b/bridges/inc/bridge.hxx
index 5e3b146217b0..a01bb42bc163 100644
--- a/bridges/inc/bridge.hxx
+++ b/bridges/inc/bridge.hxx
@@ -20,7 +20,11 @@
#ifndef INCLUDED_BRIDGES_INC_BRIDGE_HXX
#define INCLUDED_BRIDGES_INC_BRIDGE_HXX
-#include "osl/interlck.h"
+#include <sal/config.h>
+
+#include <atomic>
+#include <cstddef>
+
#include "sal/types.h"
#include "typelib/typedescription.h"
#include "uno/environment.h"
@@ -90,7 +94,7 @@ private:
Bridge * pBridge;
};
- oslInterlockedCount nRef;
+ std::atomic<std::size_t> nRef;
uno_ExtEnvironment * pCppEnv;
uno_ExtEnvironment * pUnoEnv;
diff --git a/bridges/inc/cppinterfaceproxy.hxx b/bridges/inc/cppinterfaceproxy.hxx
index ccd83660059a..00972829a53c 100644
--- a/bridges/inc/cppinterfaceproxy.hxx
+++ b/bridges/inc/cppinterfaceproxy.hxx
@@ -20,7 +20,11 @@
#ifndef INCLUDED_BRIDGES_INC_CPPINTERFACEPROXY_HXX
#define INCLUDED_BRIDGES_INC_CPPINTERFACEPROXY_HXX
-#include "osl/interlck.h"
+#include <sal/config.h>
+
+#include <atomic>
+#include <cstddef>
+
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "typelib/typedescription.h"
@@ -84,7 +88,7 @@ private:
static com::sun::star::uno::XInterface * castProxyToInterface(
CppInterfaceProxy * pProxy);
- oslInterlockedCount nRef;
+ std::atomic<std::size_t> nRef;
Bridge * pBridge;
// mapping information
diff --git a/bridges/inc/unointerfaceproxy.hxx b/bridges/inc/unointerfaceproxy.hxx
index c9697d3491a8..c76b62dd28b0 100644
--- a/bridges/inc/unointerfaceproxy.hxx
+++ b/bridges/inc/unointerfaceproxy.hxx
@@ -20,7 +20,11 @@
#ifndef INCLUDED_BRIDGES_INC_UNOINTERFACEPROXY_HXX
#define INCLUDED_BRIDGES_INC_UNOINTERFACEPROXY_HXX
-#include "osl/interlck.h"
+#include <sal/config.h>
+
+#include <atomic>
+#include <cstddef>
+
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "typelib/typedescription.h"
@@ -83,7 +87,7 @@ private:
~UnoInterfaceProxy();
- oslInterlockedCount nRef;
+ std::atomic<std::size_t> nRef;
Bridge * pBridge;
// mapping information
diff --git a/bridges/source/cpp_uno/shared/bridge.cxx b/bridges/source/cpp_uno/shared/bridge.cxx
index f752c626d253..805e56968482 100644
--- a/bridges/source/cpp_uno/shared/bridge.cxx
+++ b/bridges/source/cpp_uno/shared/bridge.cxx
@@ -24,7 +24,6 @@
#include "unointerfaceproxy.hxx"
#include "com/sun/star/uno/XInterface.hpp"
-#include "osl/interlck.h"
#include "rtl/ustring.h"
#include "sal/types.h"
#include "typelib/typedescription.h"
@@ -151,7 +150,7 @@ uno_Mapping * Bridge::createMapping(
void Bridge::acquire()
{
- if (osl_atomic_increment( &nRef ) == 1)
+ if (++nRef == 1)
{
if (bExportCpp2Uno)
{
@@ -172,7 +171,7 @@ void Bridge::acquire()
void Bridge::release()
{
- if (! osl_atomic_decrement( &nRef ))
+ if (! --nRef )
{
::uno_revokeMapping( bExportCpp2Uno ? &aCpp2Uno : &aUno2Cpp );
}
diff --git a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx
index 3fe7d98ea452..4a87eb389146 100644
--- a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx
+++ b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx
@@ -26,7 +26,6 @@
#include "com/sun/star/uno/XInterface.hpp"
#include "osl/getglobalmutex.hxx"
-#include "osl/interlck.h"
#include "osl/mutex.hxx"
#include "rtl/instance.hxx"
#include "typelib/typedescription.h"
@@ -120,7 +119,7 @@ com::sun::star::uno::XInterface * CppInterfaceProxy::create(
void CppInterfaceProxy::acquireProxy()
{
- if (osl_atomic_increment( &nRef ) == 1)
+ if (++nRef == 1)
{
// rebirth of proxy zombie
// register at cpp env
@@ -134,7 +133,7 @@ void CppInterfaceProxy::acquireProxy()
void CppInterfaceProxy::releaseProxy()
{
- if (! osl_atomic_decrement( &nRef )) // last release
+ if (! --nRef ) // last release
{
// revoke from cpp env
(*pBridge->getCppEnv()->revokeInterface)(
diff --git a/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx b/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx
index 698624ea49b0..b2c608403f34 100644
--- a/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx
+++ b/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx
@@ -22,7 +22,6 @@
#include "bridge.hxx"
#include "com/sun/star/uno/XInterface.hpp"
-#include "osl/interlck.h"
#include "typelib/typedescription.h"
#include "uno/dispatcher.h"
@@ -51,8 +50,7 @@ void freeUnoInterfaceProxy(uno_ExtEnvironment * pEnv, void * pProxy)
void acquireProxy(uno_Interface * pUnoI)
{
- if (osl_atomic_increment(
- & static_cast< UnoInterfaceProxy * >( pUnoI )->nRef ) == 1)
+ if (++static_cast< UnoInterfaceProxy * >( pUnoI )->nRef == 1)
{
// rebirth of proxy zombie
// register at uno env
@@ -73,8 +71,7 @@ void acquireProxy(uno_Interface * pUnoI)
void releaseProxy(uno_Interface * pUnoI)
{
- if (! osl_atomic_decrement(
- & static_cast< UnoInterfaceProxy * >( pUnoI )->nRef ))
+ if (! --static_cast< UnoInterfaceProxy * >( pUnoI )->nRef )
{
// revoke from uno env on last release
(*static_cast< UnoInterfaceProxy * >( pUnoI )->pBridge->getUnoEnv()->
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)(