From 4585f14b5f7340fc0da7c512c73b580b15b4f4fa Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 11 Oct 2007 17:59:59 +0200 Subject: [PATCH] bug 87: do not export the garbage collection facility from the Timer class. --- src/simulator/timer.cc | 32 ++++---------------------------- src/simulator/timer.h | 36 +----------------------------------- 2 files changed, 5 insertions(+), 63 deletions(-) diff --git a/src/simulator/timer.cc b/src/simulator/timer.cc index 2642698cb..128d11140 100644 --- a/src/simulator/timer.cc +++ b/src/simulator/timer.cc @@ -20,7 +20,6 @@ #include "timer.h" #include "simulator.h" #include "simulation-singleton.h" -#include "event-garbage-collector.h" namespace ns3 { @@ -31,16 +30,8 @@ Timer::Timer () m_impl (0) {} -Timer::Timer (enum SchedulePolicy schedulePolicy, - enum DestroyPolicy destroyPolicy) - : m_flags (schedulePolicy | destroyPolicy), - m_delay (FemtoSeconds (0)), - m_event (), - m_impl (0) -{} - -Timer::Timer (enum GarbageCollectPolicy policy) - : m_flags (GARBAGE_COLLECT), +Timer::Timer (enum DestroyPolicy destroyPolicy) + : m_flags (destroyPolicy), m_delay (FemtoSeconds (0)), m_event (), m_impl (0) @@ -149,26 +140,11 @@ void Timer::Schedule (Time delay) { NS_ASSERT (m_impl != 0); - if (m_flags & CHECK_ON_SCHEDULE) + if (m_event.IsRunning ()) { - if (m_event.IsRunning ()) - { - NS_FATAL_ERROR ("Event is still running while re-scheduling."); - } - } - else if (m_flags & CANCEL_ON_SCHEDULE) - { - m_event.Cancel (); - } - else if (m_flags & REMOVE_ON_SCHEDULE) - { - Simulator::Remove (m_event); + NS_FATAL_ERROR ("Event is still running while re-scheduling."); } m_event = m_impl->Schedule (delay); - if (m_flags & GARBAGE_COLLECT) - { - SimulationSingleton::Get ()->Track (m_event); - } } void diff --git a/src/simulator/timer.h b/src/simulator/timer.h index 969ea8ad3..7e5a8d636 100644 --- a/src/simulator/timer.h +++ b/src/simulator/timer.h @@ -43,23 +43,6 @@ class TimerImpl; class Timer { public: - enum SchedulePolicy { - /** - * This policy cancels the event before scheduling a new event - * for each call to Timer::Schedule. - */ - CANCEL_ON_SCHEDULE = (1<<0), - /** - * This policy removes the event from the simulation event list - * before scheduling a new event for each call to Timer::Schedule. - */ - REMOVE_ON_SCHEDULE = (1<<1), - /** - * This policy enforces a check before each call to Timer::Schedule - * to verify that the timer has already expired. - */ - CHECK_ON_SCHEDULE = (1<<2), - }; enum DestroyPolicy { /** * This policy cancels the event from the destructor of the Timer @@ -77,15 +60,6 @@ public: */ CHECK_ON_DESTROY = (1<<5) }; - enum GarbageCollectPolicy { - /** - * Every event scheduled with this policy is kept track of by an - * event garbage collector which makes sure that all events - * of timers with a GARBAGE_COLLECT policy are cancelled at the - * end of the simulation. - */ - GARBAGE_COLLECT = (1<<6) - }; enum State { RUNNING, EXPIRED, @@ -93,21 +67,13 @@ public: }; /** * create a timer with a default event lifetime management policy: - * - CHECK_ON_SCHEDULE * - CHECK_ON_DESTROY */ Timer (); /** - * \param scheduleFlags the event lifetime management policies to use for schedule events * \param destroyFlags the event lifetime management policies to use for destroy events */ - Timer (enum SchedulePolicy schedulePolicy, - enum DestroyPolicy destroyPolicy); - /** - * \param policy the garbage collect policy. Only one - * value is possible. - */ - Timer (enum GarbageCollectPolicy policy); + Timer (enum DestroyPolicy destroyPolicy); ~Timer (); /**