summaryrefslogtreecommitdiff
path: root/implementation/runtime
diff options
context:
space:
mode:
authorJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 00:40:03 -0800
committerJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 00:40:03 -0800
commit6cf4dc4636ded6d908e5382c9666d78f72ae8e3a (patch)
tree96daebd731fad9fc8150ce07cc09433f78c91885 /implementation/runtime
parent686cb94032c12be4981eac46efe5f62c2ba4d0e8 (diff)
downloadvSomeIP-6cf4dc4636ded6d908e5382c9666d78f72ae8e3a.tar.gz
vsomeip 2.9.12.9.1
Diffstat (limited to 'implementation/runtime')
-rw-r--r--implementation/runtime/src/application_impl.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/implementation/runtime/src/application_impl.cpp b/implementation/runtime/src/application_impl.cpp
index 7b8fd22..e3f84ef 100644
--- a/implementation/runtime/src/application_impl.cpp
+++ b/implementation/runtime/src/application_impl.cpp
@@ -1455,17 +1455,18 @@ routing_manager * application_impl::get_routing_manager() const {
}
void application_impl::main_dispatch() {
+ const std::thread::id its_id = std::this_thread::get_id();
std::unique_lock<std::mutex> its_lock(handlers_mutex_);
while (is_dispatching_) {
- if (handlers_.empty()) {
+ if (handlers_.empty() || !is_active_dispatcher(its_id)) {
// Cancel other waiting dispatcher
dispatcher_condition_.notify_all();
// Wait for new handlers to execute
- while (handlers_.empty() && is_dispatching_) {
+ while (is_dispatching_ && (handlers_.empty() || !is_active_dispatcher(its_id))) {
dispatcher_condition_.wait(its_lock);
}
} else {
- while (is_dispatching_ && !handlers_.empty()) {
+ while (is_dispatching_ && !handlers_.empty() && is_active_dispatcher(its_id)) {
std::shared_ptr<sync_handler> its_handler = handlers_.front();
handlers_.pop_front();
its_lock.unlock();
@@ -1483,6 +1484,12 @@ void application_impl::main_dispatch() {
}
}
}
+ // application was stopped
+ {
+ std::lock_guard<std::mutex> its_lock(dispatcher_mutex_);
+ dispatchers_.erase(its_id);
+ }
+ remove_elapsed_dispatchers();
its_lock.unlock();
}
@@ -1511,6 +1518,10 @@ void application_impl::dispatch() {
}
}
{
+ std::lock_guard<std::mutex> its_lock(handlers_mutex_);
+ dispatcher_condition_.notify_all();
+ }
+ {
std::lock_guard<std::mutex> its_lock(dispatcher_mutex_);
elapsed_dispatchers_.insert(its_id);
}