Kaydet (Commit) 4ecc6555 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Replace use of oslInterlockedCount with std::atomic in bridges

Change-Id: Iad47a01fd283345a2461eaaea50633bf840e5201
üst 52ffad9b
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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 );
}
......
......@@ -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)(
......
......@@ -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()->
......
......@@ -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
......
......@@ -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;
......
......@@ -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)(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment