(maybe we need an advanced singleton implementation)
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1816
270642c3-0616-0410-b53a-bc976706d245
//-/////////////////////////////////////////////////////////////////////////////////////////////////
// private members
+bool senf::ppi::EventManager::alive_ (false);
+
prefix_ void senf::ppi::EventManager::destroyModule(module::Module & module)
{
using boost::lambda::_1;
//-/////////////////////////////////////////////////////////////////////////////////////////////////
// senf::ppi::EventManager
+prefix_ bool senf::ppi::EventManager::alive()
+{
+ return alive_;
+}
+
prefix_ senf::ppi::EventManager & senf::ppi::EventManager::instance()
{
static EventManager manager;
//-/////////////////////////////////////////////////////////////////////////////////////////////////
// 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;
#define HH_SENF_PPI_EventManager_ 1
// Custom includes
+#include <boost/utility.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <senf/Scheduler/ClockService.hh>
#include "predecl.hh"
responsibility of an external component (the Scheduler)
*/
class EventManager
+ : boost::noncopyable
{
public:
//-////////////////////////////////////////////////////////////////////////
//\{
static EventManager & instance();
+ static bool alive();
// default default constructor
// default copy constructor
protected:
private:
+ EventManager();
+ ~EventManager();
+
template <class Descriptor>
void registerEvent(module::Module & module,
typename Callback<Descriptor>::type callback,
ClockService::clock_type eventTime_;
+ static bool alive_;
+
friend class detail::EventBindingBase;
friend class module::Module;
friend class EventDescriptor;
prefix_ senf::ppi::EventDescriptor::~EventDescriptor()
{
- if (binding_)
+ if (binding_ && EventManager::alive())
binding_->manager().destroyEvent(*this);
}
prefix_ void senf::ppi::module::Module::destroy()
{
- eventManager().destroyModule(*this);
+ if (EventManager::alive())
+ eventManager().destroyModule(*this);
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////