diff options
author | Juergen Gehring <juergen.gehring@bmw.de> | 2017-06-19 07:47:01 -0700 |
---|---|---|
committer | Juergen Gehring <juergen.gehring@bmw.de> | 2017-06-19 07:47:01 -0700 |
commit | 008f6c11f5371e93c06b3ed337326008d2031084 (patch) | |
tree | f25b96bab93d4b71496793d5944e054fc8d303af /include/CommonAPI/Event.hpp | |
parent | 66de998220d90116aa603d7458e245fe6094b4eb (diff) | |
download | genivi-common-api-runtime-008f6c11f5371e93c06b3ed337326008d2031084.tar.gz |
CommonAPI 3.1.123.1.12
Diffstat (limited to 'include/CommonAPI/Event.hpp')
-rw-r--r-- | include/CommonAPI/Event.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/CommonAPI/Event.hpp b/include/CommonAPI/Event.hpp index 5fbec00..67cc6dc 100644 --- a/include/CommonAPI/Event.hpp +++ b/include/CommonAPI/Event.hpp @@ -72,6 +72,7 @@ protected: void notifyListeners(const Arguments_&... _eventArguments); void notifySpecificListener(const Subscription _subscription, const Arguments_&... _eventArguments); void notifySpecificError(const Subscription _subscription, const CallStatus status); + void notifyErrorListeners(const CallStatus status); virtual void onFirstListenerAdded(const Listener &_listener) { (void)_listener; @@ -267,6 +268,37 @@ void Event<Arguments_...>::notifySpecificError(const Subscription subscription, } } +template<typename ... Arguments_> +void Event<Arguments_...>::notifyErrorListeners(const CallStatus status) { + subscriptionMutex_.lock(); + notificationMutex_.lock(); + for (auto iterator = pendingUnsubscriptions_.begin(); + iterator != pendingUnsubscriptions_.end(); + iterator++) { + subscriptions_.erase(*iterator); + } + pendingUnsubscriptions_.clear(); + + for (auto iterator = pendingSubscriptions_.begin(); + iterator != pendingSubscriptions_.end(); + iterator++) { + subscriptions_.insert(*iterator); + } + pendingSubscriptions_.clear(); + + subscriptionMutex_.unlock(); + + for (auto iterator = subscriptions_.begin(); iterator != subscriptions_.end(); iterator++) { + ErrorListener listener = std::get<1>(iterator->second); + if (listener) { + listener(status); + } + } + + notificationMutex_.unlock(); +} + + } // namespace CommonAPI #endif // COMMONAPI_EVENT_HPP_ |