summaryrefslogtreecommitdiff
path: root/include/CommonAPI/DBus/DBusServiceRegistry.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/CommonAPI/DBus/DBusServiceRegistry.hpp')
-rw-r--r--include/CommonAPI/DBus/DBusServiceRegistry.hpp62
1 files changed, 17 insertions, 45 deletions
diff --git a/include/CommonAPI/DBus/DBusServiceRegistry.hpp b/include/CommonAPI/DBus/DBusServiceRegistry.hpp
index 3181226..61a4ac5 100644
--- a/include/CommonAPI/DBus/DBusServiceRegistry.hpp
+++ b/include/CommonAPI/DBus/DBusServiceRegistry.hpp
@@ -73,7 +73,7 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
typedef std::function<void(const DBusObjectManagerStub::DBusObjectPathAndInterfacesDict)> GetAvailableServiceInstancesCallback;
- static std::shared_ptr<DBusServiceRegistry> get(std::shared_ptr<DBusProxyConnection> _connection);
+ static std::shared_ptr<DBusServiceRegistry> get(std::shared_ptr<DBusProxyConnection> _connection, bool _insert=true);
static void remove(std::shared_ptr<DBusProxyConnection> _connection);
DBusServiceRegistry(std::shared_ptr<DBusProxyConnection> dbusProxyConnection);
@@ -117,13 +117,6 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
nextSubscriptionKey(0) {
}
- DBusInterfaceNameListenersRecord(DBusInterfaceNameListenersRecord &&_other)
- : state(_other.state),
- listenerList(std::move(_other.listenerList)),
- listenersToRemove(std::move(_other.listenersToRemove)),
- nextSubscriptionKey(_other.nextSubscriptionKey){
- }
-
DBusRecordState state;
DBusServiceListenerList listenerList;
std::list<DBusServiceSubscription> listenersToRemove;
@@ -135,24 +128,16 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
struct DBusServiceListenersRecord {
DBusServiceListenersRecord()
: uniqueBusNameState(DBusRecordState::UNKNOWN),
+ promiseOnResolve(std::make_shared<std::promise<DBusRecordState>>()),
mutexOnResolve() {
}
- DBusServiceListenersRecord(DBusServiceListenersRecord&& other)
- : uniqueBusNameState(other.uniqueBusNameState),
- uniqueBusName(std::move(other.uniqueBusName)),
- promiseOnResolve(std::move(other.promiseOnResolve)),
- futureOnResolve(std::move(other.futureOnResolve)),
- mutexOnResolve(std::move(other.mutexOnResolve)),
- dbusObjectPathListenersMap(std::move(other.dbusObjectPathListenersMap)) {
- }
-
~DBusServiceListenersRecord() {};
DBusRecordState uniqueBusNameState;
std::string uniqueBusName;
- std::promise<DBusRecordState> promiseOnResolve;
+ std::shared_ptr<std::promise<DBusRecordState>> promiseOnResolve;
std::shared_future<DBusRecordState> futureOnResolve;
std::unique_lock<std::mutex>* mutexOnResolve;
@@ -165,27 +150,21 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
struct DBusObjectPathCache {
DBusObjectPathCache()
: referenceCount(0),
- state(DBusRecordState::UNKNOWN){
- }
-
- DBusObjectPathCache(DBusObjectPathCache&& other)
- : referenceCount(other.referenceCount),
- state(other.state),
- promiseOnResolve(std::move(other.promiseOnResolve)),
- futureOnResolve(std::move(other.futureOnResolve)),
- serviceName(std::move(other.serviceName)),
- dbusInterfaceNamesCache(std::move(other.dbusInterfaceNamesCache)){
+ state(DBusRecordState::UNKNOWN),
+ promiseOnResolve(std::make_shared<std::promise<DBusRecordState>>()),
+ pendingObjectManagerCalls(0) {
}
~DBusObjectPathCache() {}
size_t referenceCount;
DBusRecordState state;
- std::promise<DBusRecordState> promiseOnResolve;
+ std::shared_ptr<std::promise<DBusRecordState>> promiseOnResolve;
std::shared_future<DBusRecordState> futureOnResolve;
std::string serviceName;
std::unordered_set<std::string> dbusInterfaceNamesCache;
+ uint8_t pendingObjectManagerCalls;
};
struct DBusUniqueNameRecord {
@@ -193,13 +172,6 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
: objectPathsState(DBusRecordState::UNKNOWN) {
}
- DBusUniqueNameRecord(DBusUniqueNameRecord&& other)
- : uniqueName(std::move(other.uniqueName)),
- objectPathsState(other.objectPathsState),
- ownedBusNames(std::move(other.ownedBusNames)),
- dbusObjectPathsCache(std::move(other.dbusObjectPathsCache)) {
- }
-
std::string uniqueName;
DBusRecordState objectPathsState;
std::unordered_set<std::string> ownedBusNames;
@@ -232,10 +204,9 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
const std::string& dbusServiceUniqueName,
DBusUniqueNameRecord& dbusUniqueNameRecord);
- void releaseDBusObjectPathCacheReference(const std::string& dbusObjectPath,
- const DBusServiceListenersRecord& dbusServiceListenersRecord);
-
- bool resolveObjectPathWithObjectManager(const std::string& dbusServiceUniqueName, const std::string& dbusObjectPath);
+ bool resolveObjectPathWithObjectManager(DBusObjectPathCache& dbusObjectPathRecord,
+ const std::string& dbusServiceUniqueName,
+ const std::string& dbusObjectPath);
typedef std::function<void(const CallStatus&,
const DBusObjectManagerStub::DBusObjectPathAndInterfacesDict,
@@ -255,10 +226,6 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
const std::string& dbusServiceUniqueName,
const std::string& dbusObjectPath);
- void processManagedObject(const std::string& dbusObjectPath,
- const std::string& dbusServiceUniqueName,
- const std::string& interfaceName);
-
void onDBusDaemonProxyNameOwnerChangedEvent(const std::string& name,
const std::string& oldOwner,
const std::string& newOwner);
@@ -276,6 +243,11 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
void onDBusServiceNotAvailable(DBusServiceListenersRecord& dbusServiceListenersRecord, const std::string &_serviceName = "");
+ void notifyDBusServiceListenersLocked(const DBusUniqueNameRecord _dbusUniqueNameRecord,
+ const std::string _dbusObjectPath,
+ const std::unordered_set<std::string> _dbusInterfaceNames,
+ const DBusRecordState _dbusInterfaceNamesState);
+
void notifyDBusServiceListeners(const DBusUniqueNameRecord& dbusUniqueNameRecord,
const std::string& dbusObjectPath,
@@ -314,7 +286,7 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
std::unordered_set<std::string> dbusPredefinedServices_;
private:
- typedef std::map<std::shared_ptr<DBusProxyConnection>, std::shared_ptr<DBusServiceRegistry>> RegistryMap_t;
+ typedef std::map<DBusProxyConnection*, std::shared_ptr<DBusServiceRegistry>> RegistryMap_t;
static std::shared_ptr<RegistryMap_t> getRegistryMap() {
static std::shared_ptr<RegistryMap_t> registries(new RegistryMap_t);
return registries;