From 1b5f83a9bcfcf5b36e183eace369cdfadb5d295f Mon Sep 17 00:00:00 2001 From: Juergen Gehring Date: Thu, 25 Jan 2018 01:02:22 -0800 Subject: capicxx-dbus-runtime 3.1.12.4 --- CHANGES | 3 ++ .../DBus/DBusFreedesktopStubAdapterHelper.hpp | 25 +++++++++------- include/CommonAPI/DBus/DBusStubAdapterHelper.hpp | 35 ++++++++++++---------- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/CHANGES b/CHANGES index f077acb..02e6a1b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes ======= +v3.1.12.4 +- support 'lock functors' in AttributeDispatcher(s) + v3.1.12.3 - Fixed data race in generated StubDefault when using attributes - use eventfd instead of pipe in Watch diff --git a/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp b/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp index 42b8f92..56f2f17 100644 --- a/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp +++ b/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp @@ -41,10 +41,11 @@ class DBusGetFreedesktopAttributeStubDispatcher : public virtual DBusGetAttributeStubDispatcher, public virtual DBusGetFreedesktopAttributeStubDispatcherBase { public: + typedef typename DBusGetAttributeStubDispatcher::LockStubFunctor LockStubFunctor; typedef typename DBusGetAttributeStubDispatcher::GetStubFunctor GetStubFunctor; - DBusGetFreedesktopAttributeStubDispatcher(GetStubFunctor _getStubFunctor, AttributeDepl_ *_depl = nullptr) - : DBusGetAttributeStubDispatcher(_getStubFunctor, "v", _depl) { + DBusGetFreedesktopAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, AttributeDepl_ *_depl = nullptr) + : DBusGetAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, "v", _depl) { } virtual ~DBusGetFreedesktopAttributeStubDispatcher() {}; @@ -86,19 +87,21 @@ class DBusSetFreedesktopAttributeStubDispatcher : public virtual DBusGetFreedesktopAttributeStubDispatcher, public virtual DBusSetAttributeStubDispatcher { public: + typedef typename DBusGetAttributeStubDispatcher::LockStubFunctor LockStubFunctor; typedef typename DBusGetAttributeStubDispatcher::GetStubFunctor GetStubFunctor; typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType; typedef bool (RemoteEventHandlerType::*OnRemoteSetFunctor)(std::shared_ptr, AttributeType_); typedef void (RemoteEventHandlerType::*OnRemoteChangedFunctor)(); DBusSetFreedesktopAttributeStubDispatcher( + LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, OnRemoteSetFunctor _onRemoteSetFunctor, OnRemoteChangedFunctor _onRemoteChangedFunctor, AttributeDepl_ * _depl = nullptr) - : DBusGetAttributeStubDispatcher(_getStubFunctor, "v", _depl), - DBusGetFreedesktopAttributeStubDispatcher(_getStubFunctor, _depl), - DBusSetAttributeStubDispatcher(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl) { + : DBusGetAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, "v", _depl), + DBusGetFreedesktopAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, _depl), + DBusSetAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl) { } virtual ~DBusSetFreedesktopAttributeStubDispatcher() {}; @@ -123,6 +126,7 @@ class DBusSetFreedesktopObservableAttributeStubDispatcher : public virtual DBusSetFreedesktopAttributeStubDispatcher, public virtual DBusSetObservableAttributeStubDispatcher { public: + typedef typename DBusSetFreedesktopAttributeStubDispatcher::LockStubFunctor LockStubFunctor; typedef typename DBusSetFreedesktopAttributeStubDispatcher::GetStubFunctor GetStubFunctor; typedef typename DBusSetFreedesktopAttributeStubDispatcher::OnRemoteSetFunctor OnRemoteSetFunctor; typedef typename DBusSetFreedesktopAttributeStubDispatcher::OnRemoteChangedFunctor OnRemoteChangedFunctor; @@ -130,16 +134,17 @@ public: typedef void (StubAdapterType::*FireChangedFunctor)(const AttributeType_&); DBusSetFreedesktopObservableAttributeStubDispatcher( + LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, OnRemoteSetFunctor _onRemoteSetFunctor, OnRemoteChangedFunctor _onRemoteChangedFunctor, FireChangedFunctor _fireChangedFunctor, AttributeDepl_ *_depl = nullptr) - : DBusGetAttributeStubDispatcher(_getStubFunctor, "v", _depl), - DBusGetFreedesktopAttributeStubDispatcher(_getStubFunctor, _depl), - DBusSetAttributeStubDispatcher(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl), - DBusSetFreedesktopAttributeStubDispatcher(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _depl), - DBusSetObservableAttributeStubDispatcher(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _fireChangedFunctor, "v", _depl) { + : DBusGetAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, "v", _depl), + DBusGetFreedesktopAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, _depl), + DBusSetAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl), + DBusSetFreedesktopAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _depl), + DBusSetObservableAttributeStubDispatcher(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _fireChangedFunctor, "v", _depl) { } }; diff --git a/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp b/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp index 980d88e..d4252ab 100644 --- a/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp +++ b/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp @@ -870,11 +870,13 @@ template { public: typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType; + typedef void (StubClass_::*LockStubFunctor)(bool); typedef const AttributeType_& (StubClass_::*GetStubFunctor)(std::shared_ptr); typedef typename StubClass_::StubAdapterType StubAdapterType; typedef typename CommonAPI::Stub StubType; - DBusGetAttributeStubDispatcher(GetStubFunctor _getStubFunctor, const char *_signature, AttributeDepl_ *_depl = nullptr): + DBusGetAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, const char *_signature, AttributeDepl_ *_depl = nullptr): + lockStubFunctor_(_lockStubFunctor), getStubFunctor_(_getStubFunctor), signature_(_signature), depl_(_depl) { @@ -894,10 +896,9 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher std::shared_ptr clientId = std::make_shared(std::string(dbusMessage.getSender())); auto varDepl = CommonAPI::DBus::VariantDeployment(true, depl_); // presuming FreeDesktop variant deployment, as support for "legacy" service only - auto stubAdapter = stub->StubType::getStubAdapter(); - stubAdapter->lockAttributes(); + (stub.get()->*lockStubFunctor_)(true); auto deployable = CommonAPI::Deployable, CommonAPI::DBus::VariantDeployment>((stub.get()->*getStubFunctor_)(clientId), &varDepl); - stubAdapter->unlockAttributes(); + (stub.get()->*lockStubFunctor_)(false); _output << deployable; _output.flush(); @@ -910,10 +911,9 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher std::shared_ptr clientId = std::make_shared(std::string(dbusMessage.getSender())); - auto stubAdapter = stub->StubType::getStubAdapter(); - stubAdapter->lockAttributes(); + (stub.get()->*lockStubFunctor_)(true); auto deployable = CommonAPI::Deployable((stub.get()->*getStubFunctor_)(clientId), depl_); - stubAdapter->unlockAttributes(); + (stub.get()->*lockStubFunctor_)(false); dbusOutputStream << deployable; dbusOutputStream.flush(); @@ -926,7 +926,7 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher } } - + LockStubFunctor lockStubFunctor_; GetStubFunctor getStubFunctor_; const char* signature_; AttributeDepl_ *depl_; @@ -937,16 +937,18 @@ class DBusSetAttributeStubDispatcher: public virtual DBusGetAttributeStubDispatc public: typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType; + typedef typename DBusGetAttributeStubDispatcher::LockStubFunctor LockStubFunctor; typedef typename DBusGetAttributeStubDispatcher::GetStubFunctor GetStubFunctor; typedef bool (RemoteEventHandlerType::*OnRemoteSetFunctor)(std::shared_ptr, AttributeType_); typedef void (RemoteEventHandlerType::*OnRemoteChangedFunctor)(); - DBusSetAttributeStubDispatcher(GetStubFunctor getStubFunctor, + DBusSetAttributeStubDispatcher(LockStubFunctor lockStubFunctor, + GetStubFunctor getStubFunctor, OnRemoteSetFunctor onRemoteSetFunctor, OnRemoteChangedFunctor onRemoteChangedFunctor, const char* dbusSignature, AttributeDepl_ *_depl = nullptr) : - DBusGetAttributeStubDispatcher(getStubFunctor, dbusSignature, _depl), + DBusGetAttributeStubDispatcher(lockStubFunctor, getStubFunctor, dbusSignature, _depl), onRemoteSetFunctor_(onRemoteSetFunctor), onRemoteChangedFunctor_(onRemoteChangedFunctor) { } @@ -1019,22 +1021,24 @@ class DBusSetObservableAttributeStubDispatcher: public virtual DBusSetAttributeS public: typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType; typedef typename StubClass_::StubAdapterType StubAdapterType; + typedef typename DBusGetAttributeStubDispatcher::LockStubFunctor LockStubFunctor; typedef typename DBusSetAttributeStubDispatcher::GetStubFunctor GetStubFunctor; typedef typename DBusSetAttributeStubDispatcher::OnRemoteSetFunctor OnRemoteSetFunctor; typedef typename DBusSetAttributeStubDispatcher::OnRemoteChangedFunctor OnRemoteChangedFunctor; typedef typename CommonAPI::Stub StubType; typedef void (StubAdapterType::*FireChangedFunctor)(const AttributeType_&); - DBusSetObservableAttributeStubDispatcher(GetStubFunctor getStubFunctor, + DBusSetObservableAttributeStubDispatcher(LockStubFunctor lockStubFunctor, + GetStubFunctor getStubFunctor, OnRemoteSetFunctor onRemoteSetFunctor, OnRemoteChangedFunctor onRemoteChangedFunctor, FireChangedFunctor fireChangedFunctor, const char* dbusSignature, AttributeDepl_ *_depl = nullptr) : DBusGetAttributeStubDispatcher( - getStubFunctor, dbusSignature, _depl), + lockStubFunctor, getStubFunctor, dbusSignature, _depl), DBusSetAttributeStubDispatcher( - getStubFunctor, onRemoteSetFunctor, onRemoteChangedFunctor, dbusSignature, _depl), + lockStubFunctor, getStubFunctor, onRemoteSetFunctor, onRemoteChangedFunctor, dbusSignature, _depl), fireChangedFunctor_(fireChangedFunctor) { } @@ -1060,10 +1064,11 @@ protected: const std::shared_ptr _stub) { (void)_remoteEventHandler; + auto stubAdapter = _stub->StubType::getStubAdapter(); - stubAdapter->lockAttributes(); + (_stub.get()->*DBusGetAttributeStubDispatcher::lockStubFunctor_)(true); (stubAdapter.get()->*fireChangedFunctor_)(this->getAttributeValue(_client, _stub)); - stubAdapter->unlockAttributes(); + (_stub.get()->*DBusGetAttributeStubDispatcher::lockStubFunctor_)(false); } const FireChangedFunctor fireChangedFunctor_; -- cgit v1.2.1