From: tho Date: Wed, 19 Oct 2011 08:51:15 +0000 (+0000) Subject: PPI: fixed module destruction on shutdown if EventManger is already destroyed (like... X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=aeb7c57c3b42e83cb0b429989f9c3ab0900a76a4 PPI: fixed module destruction on shutdown if EventManger is already destroyed (like rev #1717) (maybe we need an advanced singleton implementation) git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1816 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/EventManager.cc b/senf/PPI/EventManager.cc index 9a33449..db9b8ef 100644 --- a/senf/PPI/EventManager.cc +++ b/senf/PPI/EventManager.cc @@ -45,6 +45,8 @@ //-///////////////////////////////////////////////////////////////////////////////////////////////// // private members +bool senf::ppi::EventManager::alive_ (false); + prefix_ void senf::ppi::EventManager::destroyModule(module::Module & module) { using boost::lambda::_1; diff --git a/senf/PPI/EventManager.cci b/senf/PPI/EventManager.cci index 1bfe479..66881d4 100644 --- a/senf/PPI/EventManager.cci +++ b/senf/PPI/EventManager.cci @@ -38,6 +38,11 @@ //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::ppi::EventManager +prefix_ bool senf::ppi::EventManager::alive() +{ + return alive_; +} + prefix_ senf::ppi::EventManager & senf::ppi::EventManager::instance() { static EventManager manager; @@ -57,6 +62,16 @@ prefix_ senf::ClockService::clock_type senf::ppi::EventManager::time() //-///////////////////////////////////////////////////////////////////////////////////////////////// // private members +prefix_ senf::ppi::EventManager::EventManager() +{ + alive_ = true; +} + +prefix_ senf::ppi::EventManager::~EventManager() +{ + alive_ = false; +} + prefix_ void senf::ppi::EventManager::eventTime(ClockService::clock_type time) { eventTime_ = time; diff --git a/senf/PPI/EventManager.hh b/senf/PPI/EventManager.hh index fcca5da..a9bcc2b 100644 --- a/senf/PPI/EventManager.hh +++ b/senf/PPI/EventManager.hh @@ -32,6 +32,7 @@ #define HH_SENF_PPI_EventManager_ 1 // Custom includes +#include #include #include #include "predecl.hh" @@ -51,6 +52,7 @@ namespace ppi { responsibility of an external component (the Scheduler) */ class EventManager + : boost::noncopyable { public: //-//////////////////////////////////////////////////////////////////////// @@ -69,6 +71,7 @@ namespace ppi { //\{ static EventManager & instance(); + static bool alive(); // default default constructor // default copy constructor @@ -86,6 +89,9 @@ namespace ppi { protected: private: + EventManager(); + ~EventManager(); + template void registerEvent(module::Module & module, typename Callback::type callback, @@ -101,6 +107,8 @@ namespace ppi { ClockService::clock_type eventTime_; + static bool alive_; + friend class detail::EventBindingBase; friend class module::Module; friend class EventDescriptor; diff --git a/senf/PPI/Events.cc b/senf/PPI/Events.cc index 6180da5..5343bcc 100644 --- a/senf/PPI/Events.cc +++ b/senf/PPI/Events.cc @@ -44,7 +44,7 @@ prefix_ senf::ppi::EventDescriptor::~EventDescriptor() { - if (binding_) + if (binding_ && EventManager::alive()) binding_->manager().destroyEvent(*this); } diff --git a/senf/PPI/Module.cci b/senf/PPI/Module.cci index e28da49..b138400 100644 --- a/senf/PPI/Module.cci +++ b/senf/PPI/Module.cci @@ -100,7 +100,8 @@ prefix_ senf::ppi::module::Module::Module() prefix_ void senf::ppi::module::Module::destroy() { - eventManager().destroyModule(*this); + if (EventManager::alive()) + eventManager().destroyModule(*this); } //-/////////////////////////////////////////////////////////////////////////////////////////////////