# HG changeset patch # User Mathieu Lacage # Date 1224075076 -7200 # Node ID 4eb8e926c6d7105ed5e4ea378f5b8777563255dc # Parent ca47c7015ea4649f3b0a130cbc7c37de9c59c667 rename RealtimeSimulator to WallclockSimulator diff -r ca47c7015ea4 -r 4eb8e926c6d7 samples/main-test-sync.cc --- a/samples/main-test-sync.cc Wed Oct 15 14:42:27 2008 +0200 +++ b/samples/main-test-sync.cc Wed Oct 15 14:51:16 2008 +0200 @@ -1,7 +1,7 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "ns3/simulator.h" -#include "ns3/realtime-simulator.h" +#include "ns3/wallclock-simulator.h" #include "ns3/nstime.h" #include "ns3/log.h" #include "ns3/system-thread.h" @@ -97,7 +97,7 @@ // // Exercise the realtime relative now path // - RealtimeSimulator::ScheduleRealtimeNow (&inserted_function); + WallclockSimulator::ScheduleNow (&inserted_function); usleep (1000); } } @@ -112,7 +112,7 @@ // // Exercise the realtime relative schedule path // - RealtimeSimulator::ScheduleRealtime (Seconds (0), &inserted_function); + WallclockSimulator::Schedule (Seconds (0), &inserted_function); usleep (1000); } } @@ -126,9 +126,9 @@ FakeNetDevice fnd; // - // Make sure ScheduleRealNow works when the system isn't running + // Make sure ScheduleNow works when the system isn't running // - RealtimeSimulator::ScheduleRealtimeNow(&first_function); + WallclockSimulator::ScheduleNow(&first_function); // // drive the progression of m_currentTs at a ten millisecond rate diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/default-simulator-impl.cc --- a/src/simulator/default-simulator-impl.cc Wed Oct 15 14:42:27 2008 +0200 +++ b/src/simulator/default-simulator-impl.cc Wed Oct 15 14:51:16 2008 +0200 @@ -321,12 +321,12 @@ } void -DefaultSimulatorImpl::ScheduleRealtime (Time const &time, EventImpl *event) +DefaultSimulatorImpl::ScheduleWallclock (Time const &time, EventImpl *event) { NS_FATAL_ERROR ("not implemented"); } void -DefaultSimulatorImpl::ScheduleRealtimeNow (EventImpl *event) +DefaultSimulatorImpl::ScheduleWallclockNow (EventImpl *event) { NS_FATAL_ERROR ("not implemented"); } diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/default-simulator-impl.h --- a/src/simulator/default-simulator-impl.h Wed Oct 15 14:42:27 2008 +0200 +++ b/src/simulator/default-simulator-impl.h Wed Oct 15 14:51:16 2008 +0200 @@ -59,8 +59,8 @@ virtual Time GetMaximumSimulationTime (void) const; virtual void SetScheduler (Ptr scheduler); virtual Ptr GetScheduler (void) const; - virtual void ScheduleRealtime (Time const &time, EventImpl *event); - virtual void ScheduleRealtimeNow (EventImpl *event); + virtual void ScheduleWallclock (Time const &time, EventImpl *event); + virtual void ScheduleWallclockNow (EventImpl *event); private: void ProcessOneEvent (void); diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/realtime-simulator-impl.cc --- a/src/simulator/realtime-simulator-impl.cc Wed Oct 15 14:42:27 2008 +0200 +++ b/src/simulator/realtime-simulator-impl.cc Wed Oct 15 14:51:16 2008 +0200 @@ -647,7 +647,7 @@ // Schedule an event for a _relative_ time in the future. // void -RealtimeSimulatorImpl::ScheduleRealtime (Time const &time, EventImpl *impl) +RealtimeSimulatorImpl::ScheduleWallclock (Time const &time, EventImpl *impl) { NS_LOG_FUNCTION (time << impl); @@ -656,7 +656,7 @@ CriticalSection cs (m_mutex); uint64_t ts = m_synchronizer->GetCurrentRealtime () + time.GetTimeStep (); - NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtime(): schedule for time < m_currentTs"); + NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleWallClock(): schedule for time < m_currentTs"); Scheduler::Event ev; ev.impl = impl; ev.key.m_ts = ts; @@ -670,7 +670,7 @@ } void -RealtimeSimulatorImpl::ScheduleRealtimeNow (EventImpl *impl) +RealtimeSimulatorImpl::ScheduleWallclockNow (EventImpl *impl) { NS_LOG_FUNCTION_NOARGS (); { @@ -681,7 +681,7 @@ // realtime clock. If we're not, then m_currentTs is were we stopped. // uint64_t ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs; - NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealrimeNow(): schedule for time < m_currentTs"); + NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleWallclockNow(): schedule for time < m_currentTs"); Scheduler::Event ev; ev.impl = impl; ev.key.m_ts = ts; diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/realtime-simulator-impl.h --- a/src/simulator/realtime-simulator-impl.h Wed Oct 15 14:42:27 2008 +0200 +++ b/src/simulator/realtime-simulator-impl.h Wed Oct 15 14:51:16 2008 +0200 @@ -78,8 +78,8 @@ virtual Time GetMaximumSimulationTime (void) const; virtual void SetScheduler (Ptr scheduler); virtual Ptr GetScheduler (void) const; - virtual void ScheduleRealtime (Time const &time, EventImpl *event); - virtual void ScheduleRealtimeNow (EventImpl *event); + virtual void ScheduleWallclock (Time const &time, EventImpl *event); + virtual void ScheduleWallclockNow (EventImpl *event); Time RealtimeNow (void) const; diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/realtime-simulator.h --- a/src/simulator/realtime-simulator.h Wed Oct 15 14:42:27 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,475 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2008 University of Washington - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef REALTIME_SIMULATOR_H -#define REALTIME_SIMULATOR_H - -#include "simulator.h" -#include "make-event.h" - -namespace ns3 { - -/** - * \ingroup simulator - * - * \brief Extension class to control the scheduling of real-time simulation - * events. Intended to be used by threads driven by "external" system - * events and will schedule events using the current real-time instead of - * the current simulation time. - */ -class RealtimeSimulator -{ -public: - /** - * Schedule an event to expire at the relative real-time "time" - * is reached. This can be thought of as scheduling an event - * for the current real-time plus the Time passed as a parameter - * - * When the event expires (when it becomes due to be run), the - * input method will be invoked on the input object. - * - * @param time the relative expiration time of the event. - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj); - - /** - * @param time the relative expiration time of the event. - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @param time the relative expiration time of the event. - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @param time the relative expiration time of the event. - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @param time the relative expiration time of the event. - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @param time the relative expiration time of the event. - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - * @param a5 the fifth argument to pass to the invoked method - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** - * @param time the relative expiration time of the event. - * @param f the function to invoke - * @returns an id for the scheduled event. - */ - static void ScheduleRealtime (Time const &time, void (*f) (void)); - - /** - * @param time the relative expiration time of the event. - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, void (*f) (U1), T1 a1); - - /** - * @param time the relative expiration time of the event. - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2); - - /** - * @param time the relative expiration time of the event. - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @param time the relative expiration time of the event. - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @param time the relative expiration time of the event. - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - * @param a5 the fifth argument to pass to the function to invoke - * @returns an id for the scheduled event. - */ - template - static void ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - - /** - * Schedule an event to expire Now. All events scheduled to - * to expire "Now" are scheduled FIFO, after all normal events - * have expired. - * - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - */ - template - static void ScheduleRealtimeNow (MEM mem_ptr, OBJ obj); - - /** - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - */ - template - static void ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1); - - /** - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - */ - template - static void ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); - - /** - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - */ - template - static void ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); - - /** - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - */ - template - static void ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4); - /** - * @param mem_ptr member method pointer to invoke - * @param obj the object on which to invoke the member method - * @param a1 the first argument to pass to the invoked method - * @param a2 the second argument to pass to the invoked method - * @param a3 the third argument to pass to the invoked method - * @param a4 the fourth argument to pass to the invoked method - * @param a5 the fifth argument to pass to the invoked method - */ - template - static void ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - /** - * @param f the function to invoke - */ - static void ScheduleRealtimeNow (void (*f) (void)); - - /** - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - */ - template - static void ScheduleRealtimeNow (void (*f) (U1), T1 a1); - - /** - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - */ - template - static void ScheduleRealtimeNow (void (*f) (U1,U2), T1 a1, T2 a2); - - /** - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - */ - template - static void ScheduleRealtimeNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); - - /** - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - */ - template - static void ScheduleRealtimeNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); - - /** - * @param f the function to invoke - * @param a1 the first argument to pass to the function to invoke - * @param a2 the second argument to pass to the function to invoke - * @param a3 the third argument to pass to the function to invoke - * @param a4 the fourth argument to pass to the function to invoke - * @param a5 the fifth argument to pass to the function to invoke - */ - template - static void ScheduleRealtimeNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); - -private: - RealtimeSimulator (); - ~RealtimeSimulator (); - static void ScheduleRealtime (const Time &delay, EventImpl *impl); - static void ScheduleRealtimeNow (EventImpl *impl); -}; - -template -void RealtimeSimulator::ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj) -{ - return ScheduleRealtime (time, MakeEvent (mem_ptr, obj)); -} - -template -void RealtimeScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1) -{ - return ScheduleRealtime (time, MakeEvent (mem_ptr, obj, a1)); -} - -template -void RealtimeScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) -{ - return ScheduleRealtime (time, MakeEvent (mem_ptr, obj, a1, a2)); -} - -template -void RealtimeScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) -{ - return ScheduleRealtime (time, MakeEvent (mem_ptr, obj, a1, a2, a3)); -} - -template -void RealtimeScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) -{ - return ScheduleRealtime (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); -} - -template -void RealtimeScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return ScheduleRealtime (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); -} - -template -void RealtimeScheduleRealtime (Time const &time, void (*f) (U1), T1 a1) -{ - return ScheduleRealtime (time, MakeEvent (f, a1)); -} - -template -void RealtimeScheduleRealtime (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2) -{ - return ScheduleRealtime (time, MakeEvent (f, a1, a2)); -} - -template -void RealtimeScheduleRealtime (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) -{ - return ScheduleRealtime (time, MakeEvent (f, a1, a2, a3)); -} - -template -void RealtimeScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) -{ - return ScheduleRealtime (time, MakeEvent (f, a1, a2, a3, a4)); -} - -template -void RealtimeScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return ScheduleRealtime (time, MakeEvent (f, a1, a2, a3, a4, a5)); -} - -template -void -RealtimeScheduleRealtimeNow (MEM mem_ptr, OBJ obj) -{ - return ScheduleRealtimeNow (MakeEvent (mem_ptr, obj)); -} - -template -void -RealtimeScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1) -{ - return ScheduleRealtimeNow (MakeEvent (mem_ptr, obj, a1)); -} - -template -void -RealtimeScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) -{ - return ScheduleRealtimeNow (MakeEvent (mem_ptr, obj, a1, a2)); -} - -template -void -RealtimeScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) -{ - return ScheduleRealtimeNow (MakeEvent (mem_ptr, obj, a1, a2, a3)); -} - -template -void -RealtimeScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) -{ - return ScheduleRealtimeNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); -} - -template -void -RealtimeScheduleRealtimeNow (MEM mem_ptr, OBJ obj, - T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return ScheduleRealtimeNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); -} - -template -void -RealtimeScheduleRealtimeNow (void (*f) (U1), T1 a1) -{ - return ScheduleRealtimeNow (MakeEvent (f, a1)); -} - -template -void -RealtimeScheduleRealtimeNow (void (*f) (U1,U2), T1 a1, T2 a2) -{ - return ScheduleRealtimeNow (MakeEvent (f, a1, a2)); -} - -template -void -RealtimeScheduleRealtimeNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) -{ - return ScheduleRealtimeNow (MakeEvent (f, a1, a2, a3)); -} - -template -void -RealtimeScheduleRealtimeNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) -{ - return ScheduleRealtimeNow (MakeEvent (f, a1, a2, a3, a4)); -} - -template -void -RealtimeScheduleRealtimeNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) -{ - return ScheduleRealtimeNow (MakeEvent (f, a1, a2, a3, a4, a5)); -} - -} // namespace ns3 - -#endif /* REALTIME_SIMULATOR_H */ diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/simulator-impl.h --- a/src/simulator/simulator-impl.h Wed Oct 15 14:42:27 2008 +0200 +++ b/src/simulator/simulator-impl.h Wed Oct 15 14:51:16 2008 +0200 @@ -52,8 +52,8 @@ virtual Time GetMaximumSimulationTime (void) const = 0; virtual void SetScheduler (Ptr scheduler) = 0; virtual Ptr GetScheduler (void) const = 0; - virtual void ScheduleRealtime (Time const &time, EventImpl *event) = 0; - virtual void ScheduleRealtimeNow (EventImpl *event) = 0; + virtual void ScheduleWallclock (Time const &time, EventImpl *event) = 0; + virtual void ScheduleWallclockNow (EventImpl *event) = 0; }; } // namespace ns3 diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/simulator.cc --- a/src/simulator/simulator.cc Wed Oct 15 14:42:27 2008 +0200 +++ b/src/simulator/simulator.cc Wed Oct 15 14:51:16 2008 +0200 @@ -19,7 +19,7 @@ */ #include "simulator.h" -#include "realtime-simulator.h" +#include "wallclock-simulator.h" #include "simulator-impl.h" #include "default-simulator-impl.h" #include "realtime-simulator-impl.h" @@ -289,31 +289,31 @@ void -RealtimeSimulator::ScheduleRealtime (Time const &time, EventImpl *ev) +WallclockSimulator::Schedule (Time const &time, EventImpl *ev) { NS_LOG_FUNCTION (time << ev); - return GetImpl ()->ScheduleRealtime (time, ev); + return GetImpl ()->ScheduleWallclock (time, ev); } void -RealtimeSimulator::ScheduleRealtimeNow (EventImpl *ev) +WallclockSimulator::ScheduleNow (EventImpl *ev) { NS_LOG_FUNCTION (ev); - return GetImpl ()->ScheduleRealtimeNow (ev); + return GetImpl ()->ScheduleWallclockNow (ev); } void -RealtimeSimulator::ScheduleRealtime (Time const &time, void (*f) (void)) +WallclockSimulator::Schedule (Time const &time, void (*f) (void)) { NS_LOG_FUNCTION (time << f); - return ScheduleRealtime (time, MakeEvent (f)); + return WallclockSimulator::Schedule (time, MakeEvent (f)); } void -RealtimeSimulator::ScheduleRealtimeNow (void (*f) (void)) +WallclockSimulator::ScheduleNow (void (*f) (void)) { NS_LOG_FUNCTION (f); - return ScheduleRealtimeNow (MakeEvent (f)); + return WallclockSimulator::ScheduleNow (MakeEvent (f)); } diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/wallclock-simulator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/simulator/wallclock-simulator.h Wed Oct 15 14:51:16 2008 +0200 @@ -0,0 +1,475 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2008 University of Washington + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef WALLCLOCK_SIMULATOR_H +#define WALLCLOCK_SIMULATOR_H + +#include "simulator.h" +#include "make-event.h" + +namespace ns3 { + +/** + * \ingroup simulator + * + * \brief Extension class to control the scheduling of real-time simulation + * events. Intended to be used by threads driven by "external" system + * events and will schedule events using the current real-time instead of + * the current simulation time. + */ +class WallclockSimulator +{ +public: + /** + * Schedule an event to expire at the relative real-time "time" + * is reached. This can be thought of as scheduling an event + * for the current real-time plus the Time passed as a parameter + * + * When the event expires (when it becomes due to be run), the + * input method will be invoked on the input object. + * + * @param time the relative expiration time of the event. + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, MEM mem_ptr, OBJ obj); + + /** + * @param time the relative expiration time of the event. + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1); + + /** + * @param time the relative expiration time of the event. + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); + + /** + * @param time the relative expiration time of the event. + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); + + /** + * @param time the relative expiration time of the event. + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); + + /** + * @param time the relative expiration time of the event. + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + * @param a5 the fifth argument to pass to the invoked method + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + /** + * @param time the relative expiration time of the event. + * @param f the function to invoke + * @returns an id for the scheduled event. + */ + static void Schedule (Time const &time, void (*f) (void)); + + /** + * @param time the relative expiration time of the event. + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, void (*f) (U1), T1 a1); + + /** + * @param time the relative expiration time of the event. + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2); + + /** + * @param time the relative expiration time of the event. + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); + + /** + * @param time the relative expiration time of the event. + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + * @param a4 the fourth argument to pass to the function to invoke + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); + + /** + * @param time the relative expiration time of the event. + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + * @param a4 the fourth argument to pass to the function to invoke + * @param a5 the fifth argument to pass to the function to invoke + * @returns an id for the scheduled event. + */ + template + static void Schedule (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + + /** + * Schedule an event to expire Now. All events scheduled to + * to expire "Now" are scheduled FIFO, after all normal events + * have expired. + * + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + */ + template + static void ScheduleNow (MEM mem_ptr, OBJ obj); + + /** + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + */ + template + static void ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1); + + /** + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + */ + template + static void ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); + + /** + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + */ + template + static void ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); + + /** + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + */ + template + static void ScheduleNow (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4); + /** + * @param mem_ptr member method pointer to invoke + * @param obj the object on which to invoke the member method + * @param a1 the first argument to pass to the invoked method + * @param a2 the second argument to pass to the invoked method + * @param a3 the third argument to pass to the invoked method + * @param a4 the fourth argument to pass to the invoked method + * @param a5 the fifth argument to pass to the invoked method + */ + template + static void ScheduleNow (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + /** + * @param f the function to invoke + */ + static void ScheduleNow (void (*f) (void)); + + /** + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + */ + template + static void ScheduleNow (void (*f) (U1), T1 a1); + + /** + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + */ + template + static void ScheduleNow (void (*f) (U1,U2), T1 a1, T2 a2); + + /** + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + */ + template + static void ScheduleNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); + + /** + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + * @param a4 the fourth argument to pass to the function to invoke + */ + template + static void ScheduleNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); + + /** + * @param f the function to invoke + * @param a1 the first argument to pass to the function to invoke + * @param a2 the second argument to pass to the function to invoke + * @param a3 the third argument to pass to the function to invoke + * @param a4 the fourth argument to pass to the function to invoke + * @param a5 the fifth argument to pass to the function to invoke + */ + template + static void ScheduleNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + +private: + WallclockSimulator (); + ~WallclockSimulator (); + static void Schedule (const Time &delay, EventImpl *impl); + static void ScheduleNow (EventImpl *impl); +}; + +template +void WallclockSimulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj) +{ + return Schedule (time, MakeEvent (mem_ptr, obj)); +} + +template +void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1) +{ + return Schedule (time, MakeEvent (mem_ptr, obj, a1)); +} + +template +void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +{ + return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2)); +} + +template +void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +{ + return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3)); +} + +template +void Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +{ + return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); +} + +template +void Schedule (Time const &time, MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +{ + return Schedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); +} + +template +void Schedule (Time const &time, void (*f) (U1), T1 a1) +{ + return Schedule (time, MakeEvent (f, a1)); +} + +template +void Schedule (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2) +{ + return Schedule (time, MakeEvent (f, a1, a2)); +} + +template +void Schedule (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) +{ + return Schedule (time, MakeEvent (f, a1, a2, a3)); +} + +template +void Schedule (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) +{ + return Schedule (time, MakeEvent (f, a1, a2, a3, a4)); +} + +template +void Schedule (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +{ + return Schedule (time, MakeEvent (f, a1, a2, a3, a4, a5)); +} + +template +void +ScheduleNow (MEM mem_ptr, OBJ obj) +{ + return ScheduleNow (MakeEvent (mem_ptr, obj)); +} + +template +void +ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1) +{ + return ScheduleNow (MakeEvent (mem_ptr, obj, a1)); +} + +template +void +ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +{ + return ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2)); +} + +template +void +ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +{ + return ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3)); +} + +template +void +ScheduleNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +{ + return ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); +} + +template +void +ScheduleNow (MEM mem_ptr, OBJ obj, + T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +{ + return ScheduleNow (MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); +} + +template +void +ScheduleNow (void (*f) (U1), T1 a1) +{ + return ScheduleNow (MakeEvent (f, a1)); +} + +template +void +ScheduleNow (void (*f) (U1,U2), T1 a1, T2 a2) +{ + return ScheduleNow (MakeEvent (f, a1, a2)); +} + +template +void +ScheduleNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) +{ + return ScheduleNow (MakeEvent (f, a1, a2, a3)); +} + +template +void +ScheduleNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) +{ + return ScheduleNow (MakeEvent (f, a1, a2, a3, a4)); +} + +template +void +ScheduleNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +{ + return ScheduleNow (MakeEvent (f, a1, a2, a3, a4, a5)); +} + +} // namespace ns3 + +#endif /* WALLCLOCK_SIMULATOR_H */ diff -r ca47c7015ea4 -r 4eb8e926c6d7 src/simulator/wscript --- a/src/simulator/wscript Wed Oct 15 14:42:27 2008 +0200 +++ b/src/simulator/wscript Wed Oct 15 14:51:16 2008 +0200 @@ -76,7 +76,7 @@ 'event-id.h', 'event-impl.h', 'simulator.h', - 'realtime-simulator.h', + 'wallclock-simulator.h', 'simulator-impl.h', 'default-simulator-impl.h', 'scheduler.h',