Clarify that Time arguments to Schedule are all delays wrt Now.

This commit is contained in:
Peter D. Barnes, Jr. committed 2015-07-21 12:20:12 -07:00
1 parent 69dd251a0f
commit 4d180f672c
13 files changed
+167 -159

No files matched your search

+11 -10
View File
@@ -213,22 +213,22 @@ DefaultSimulatorImpl::Stop (void)
}
void
DefaultSimulatorImpl::Stop (Time const &time)
DefaultSimulatorImpl::Stop (Time const &delay)
{
NS_LOG_FUNCTION (this << time.GetTimeStep ());
Simulator::Schedule (time, &Simulator::Stop);
NS_LOG_FUNCTION (this << delay.GetTimeStep ());
Simulator::Schedule (delay, &Simulator::Stop);
}
//
// Schedule an event for a _relative_ time in the future.
//
EventId
DefaultSimulatorImpl::Schedule (Time const &time, EventImpl *event)
DefaultSimulatorImpl::Schedule (Time const &delay, EventImpl *event)
{
NS_LOG_FUNCTION (this << time.GetTimeStep () << event);
NS_LOG_FUNCTION (this << delay.GetTimeStep () << event);
NS_ASSERT_MSG (SystemThread::Equals (m_main), "Simulator::Schedule Thread-unsafe invocation!");
Time tAbsolute = time + TimeStep (m_currentTs);
Time tAbsolute = delay + TimeStep (m_currentTs);
NS_ASSERT (tAbsolute.IsPositive ());
NS_ASSERT (tAbsolute >= TimeStep (m_currentTs));
@@ -244,13 +244,13 @@ DefaultSimulatorImpl::Schedule (Time const &time, EventImpl *event)
}
void
DefaultSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event)
DefaultSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event)
{
NS_LOG_FUNCTION (this << context << time.GetTimeStep () << event);
NS_LOG_FUNCTION (this << context << delay.GetTimeStep () << event);
if (SystemThread::Equals (m_main))
{
Time tAbsolute = time + TimeStep (m_currentTs);
Time tAbsolute = delay + TimeStep (m_currentTs);
Scheduler::Event ev;
ev.impl = event;
ev.key.m_ts = (uint64_t) tAbsolute.GetTimeStep ();
@@ -264,7 +264,8 @@ DefaultSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, E
{
EventWithContext ev;
ev.context = context;
ev.timestamp = time.GetTimeStep ();
// Current time added in ProcessEventsWithContext()
ev.timestamp = delay.GetTimeStep ();
ev.event = event;
{
CriticalSection cs (m_eventsWithContextMutex);
+3 -3
View File
@@ -55,9 +55,9 @@ public:
virtual void Destroy ();
virtual bool IsFinished (void) const;
virtual void Stop (void);
virtual void Stop (Time const &time);
virtual EventId Schedule (Time const &time, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
virtual void Stop (Time const &delay);
virtual EventId Schedule (Time const &delay, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event);
virtual EventId ScheduleNow (EventImpl *event);
virtual EventId ScheduleDestroy (EventImpl *event);
virtual void Remove (const EventId &id);
+10 -10
View File
@@ -499,19 +499,19 @@ RealtimeSimulatorImpl::Stop (void)
}
void
RealtimeSimulatorImpl::Stop (Time const &time)
RealtimeSimulatorImpl::Stop (Time const &delay)
{
NS_LOG_FUNCTION (this << time);
Simulator::Schedule (time, &Simulator::Stop);
NS_LOG_FUNCTION (this << delay);
Simulator::Schedule (delay, &Simulator::Stop);
}
//
// Schedule an event for a _relative_ time in the future.
//
EventId
RealtimeSimulatorImpl::Schedule (Time const &time, EventImpl *impl)
RealtimeSimulatorImpl::Schedule (Time const &delay, EventImpl *impl)
{
NS_LOG_FUNCTION (this << time << impl);
NS_LOG_FUNCTION (this << delay << impl);
Scheduler::Event ev;
{
@@ -522,7 +522,7 @@ RealtimeSimulatorImpl::Schedule (Time const &time, EventImpl *impl)
// multi-threaded, we need this calculation to be atomic. You can see it is
// here since we are running in a CriticalSection.
//
Time tAbsolute = Simulator::Now () + time;
Time tAbsolute = Simulator::Now () + delay;
NS_ASSERT_MSG (tAbsolute.IsPositive (), "RealtimeSimulatorImpl::Schedule(): Negative time");
NS_ASSERT_MSG (tAbsolute >= TimeStep (m_currentTs), "RealtimeSimulatorImpl::Schedule(): time < m_currentTs");
ev.impl = impl;
@@ -539,9 +539,9 @@ RealtimeSimulatorImpl::Schedule (Time const &time, EventImpl *impl)
}
void
RealtimeSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, EventImpl *impl)
RealtimeSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *impl)
{
NS_LOG_FUNCTION (this << context << time << impl);
NS_LOG_FUNCTION (this << context << delay << impl);
{
CriticalSection cs (m_mutex);
@@ -549,7 +549,7 @@ RealtimeSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time,
if (SystemThread::Equals (m_main))
{
ts = m_currentTs + time.GetTimeStep ();
ts = m_currentTs + delay.GetTimeStep ();
}
else
{
@@ -558,7 +558,7 @@ RealtimeSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time,
// realtime clock. If we're not, then m_currentTs is where we stopped.
//
ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs;
ts += time.GetTimeStep ();
ts += delay.GetTimeStep ();
}
NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtime(): schedule for time < m_currentTs");
+5 -5
View File
@@ -92,9 +92,9 @@ public:
virtual void Destroy ();
virtual bool IsFinished (void) const;
virtual void Stop (void);
virtual void Stop (Time const &time);
virtual EventId Schedule (Time const &time, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
virtual void Stop (Time const &delay);
virtual EventId Schedule (Time const &delay, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event);
virtual EventId ScheduleNow (EventImpl *event);
virtual EventId ScheduleDestroy (EventImpl *event);
virtual void Remove (const EventId &ev);
@@ -109,9 +109,9 @@ public:
virtual uint32_t GetContext (void) const;
/** \copydoc ScheduleWithContext */
void ScheduleRealtimeWithContext (uint32_t context, Time const &time, EventImpl *event);
void ScheduleRealtimeWithContext (uint32_t context, Time const &delay, EventImpl *event);
/** \copydoc Schedule */
void ScheduleRealtime (Time const &time, EventImpl *event);
void ScheduleRealtime (Time const &delay, EventImpl *event);
/**
* \copybrief ScheduleNow
*
+3 -3
View File
@@ -93,7 +93,7 @@ public:
* current simulation time.
* \param time The stop time, relative to the current time.
*/
virtual void Stop (Time const &time) = 0;
virtual void Stop (Time const &delay) = 0;
/**
* Schedule a future event execution (in the same context).
*
@@ -101,7 +101,7 @@ public:
* \param event The event to schedule.
* \returns A unique identifier for the newly-scheduled event.
*/
virtual EventId Schedule (Time const &time, EventImpl *event) = 0;
virtual EventId Schedule (Time const &delay, EventImpl *event) = 0;
/**
* Schedule a future event execution (in a different context).
*
@@ -110,7 +110,7 @@ public:
* \param event The event to schedule.
* \returns A unique identifier for the newly-scheduled event.
*/
virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event) = 0;
virtual void ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event) = 0;
/**
* Schedule an event to run at the current virtual time.
*
+11 -11
View File
@@ -213,10 +213,10 @@ Simulator::Stop (void)
}
void
Simulator::Stop (Time const &time)
Simulator::Stop (Time const &delay)
{
NS_LOG_FUNCTION (time);
GetImpl ()->Stop (time);
NS_LOG_FUNCTION (delay);
GetImpl ()->Stop (delay);
}
Time
@@ -236,9 +236,9 @@ Simulator::GetDelayLeft (const EventId &id)
}
EventId
Simulator::Schedule (Time const &time, const Ptr<EventImpl> &ev)
Simulator::Schedule (Time const &delay, const Ptr<EventImpl> &event)
{
return DoSchedule (time, GetPointer (ev));
return DoSchedule (delay, GetPointer (event));
}
EventId
@@ -247,9 +247,9 @@ Simulator::ScheduleNow (const Ptr<EventImpl> &ev)
return DoScheduleNow (GetPointer (ev));
}
void
Simulator::ScheduleWithContext (uint32_t context, const Time &time, EventImpl *impl)
Simulator::ScheduleWithContext (uint32_t context, const Time &delay, EventImpl *impl)
{
return GetImpl ()->ScheduleWithContext (context, time, impl);
return GetImpl ()->ScheduleWithContext (context, delay, impl);
}
EventId
Simulator::ScheduleDestroy (const Ptr<EventImpl> &ev)
@@ -274,15 +274,15 @@ Simulator::DoScheduleDestroy (EventImpl *impl)
EventId
Simulator::Schedule (Time const &time, void (*f)(void))
Simulator::Schedule (Time const &delay, void (*f)(void))
{
return DoSchedule (time, MakeEvent (f));
return DoSchedule (delay, MakeEvent (f));
}
void
Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f)(void))
Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void))
{
return ScheduleWithContext (context, time, MakeEvent (f));
return ScheduleWithContext (context, delay, MakeEvent (f));
}
EventId
+87 -80
View File
@@ -125,7 +125,7 @@ public:
static void Stop (void);
/** \copydoc SimulatorImpl::Stop(Time const &) */
static void Stop (Time const &time);
static void Stop (Time const &delay);
/**
* \name Schedule events (in the same context) to run at a future time.
@@ -146,7 +146,7 @@ public:
* @returns an id for the scheduled event.
*/
template <typename MEM, typename OBJ>
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj);
static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj);
/**
* @param time the relative expiration time of the event.
@@ -156,7 +156,7 @@ public:
* @returns an id for the scheduled event.
*/
template <typename MEM, typename OBJ, typename T1>
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1);
static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
/**
* @param time the relative expiration time of the event.
@@ -167,7 +167,7 @@ public:
* @returns an id for the scheduled event.
*/
template <typename MEM, typename OBJ, typename T1, typename T2>
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
/**
* @param time the relative expiration time of the event.
@@ -180,7 +180,7 @@ public:
*/
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3>
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
/**
* @param time the relative expiration time of the event.
@@ -194,7 +194,7 @@ public:
*/
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4>
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
static EventId Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
/**
* @param time the relative expiration time of the event.
@@ -209,14 +209,14 @@ public:
*/
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4, typename T5>
static EventId Schedule (Time const &time, MEM mem_ptr, OBJ obj,
static EventId Schedule (Time const &delay, 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 EventId Schedule (Time const &time, void (*f)(void));
static EventId Schedule (Time const &delay, void (*f)(void));
/**
* @param time the relative expiration time of the event.
@@ -225,7 +225,7 @@ public:
* @returns an id for the scheduled event.
*/
template <typename U1, typename T1>
static EventId Schedule (Time const &time, void (*f)(U1), T1 a1);
static EventId Schedule (Time const &delay, void (*f)(U1), T1 a1);
/**
* @param time the relative expiration time of the event.
@@ -234,8 +234,9 @@ public:
* @param a2 the second argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
template <typename U1, typename U2, typename T1, typename T2>
static EventId Schedule (Time const &time, void (*f)(U1,U2), T1 a1, T2 a2);
template <typename U1, typename U2,
typename T1, typename T2>
static EventId Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
/**
* @param time the relative expiration time of the event.
@@ -245,8 +246,9 @@ public:
* @param a3 the third argument to pass to the function to invoke
* @returns an id for the scheduled event.
*/
template <typename U1, typename U2, typename U3, typename T1, typename T2, typename T3>
static EventId Schedule (Time const &time, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
template <typename U1, typename U2, typename U3,
typename T1, typename T2, typename T3>
static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
/**
* @param time the relative expiration time of the event.
@@ -259,7 +261,7 @@ public:
*/
template <typename U1, typename U2, typename U3, typename U4,
typename T1, typename T2, typename T3, typename T4>
static EventId Schedule (Time const &time, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
/**
* @param time the relative expiration time of the event.
@@ -273,7 +275,7 @@ public:
*/
template <typename U1, typename U2, typename U3, typename U4, typename U5,
typename T1, typename T2, typename T3, typename T4, typename T5>
static EventId Schedule (Time const &time, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
static EventId Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
/** @} */
@@ -294,7 +296,7 @@ public:
* @param obj the object on which to invoke the member method
*/
template <typename MEM, typename OBJ>
static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj);
static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj);
/**
* This method is thread-safe: it can be called from any thread.
@@ -306,7 +308,7 @@ public:
* @param a1 the first argument to pass to the invoked method
*/
template <typename MEM, typename OBJ, typename T1>
static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1);
static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1);
/**
* This method is thread-safe: it can be called from any thread.
@@ -319,7 +321,7 @@ public:
* @param a2 the second argument to pass to the invoked method
*/
template <typename MEM, typename OBJ, typename T1, typename T2>
static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2);
/**
* This method is thread-safe: it can be called from any thread.
@@ -334,7 +336,7 @@ public:
*/
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3>
static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3);
/**
* This method is thread-safe: it can be called from any thread.
@@ -350,7 +352,7 @@ public:
*/
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4>
static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4);
/**
* This method is thread-safe: it can be called from any thread.
@@ -367,7 +369,7 @@ public:
*/
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4, typename T5>
static void ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
static void ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
/**
* This method is thread-safe: it can be called from any thread.
@@ -376,7 +378,7 @@ public:
* @param context user-specified context parameter
* @param f the function to invoke
*/
static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(void));
static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(void));
/**
* This method is thread-safe: it can be called from any thread.
@@ -386,8 +388,9 @@ public:
* @param f the function to invoke
* @param a1 the first argument to pass to the function to invoke
*/
template <typename U1, typename T1>
static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1), T1 a1);
template <typename U1,
typename T1>
static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1);
/**
* This method is thread-safe: it can be called from any thread.
@@ -398,8 +401,9 @@ public:
* @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 <typename U1, typename U2, typename T1, typename T2>
static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2), T1 a1, T2 a2);
template <typename U1, typename U2,
typename T1, typename T2>
static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2);
/**
* This method is thread-safe: it can be called from any thread.
@@ -411,8 +415,9 @@ public:
* @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 <typename U1, typename U2, typename U3, typename T1, typename T2, typename T3>
static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
template <typename U1, typename U2, typename U3,
typename T1, typename T2, typename T3>
static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3);
/**
* This method is thread-safe: it can be called from any thread.
@@ -427,7 +432,7 @@ public:
*/
template <typename U1, typename U2, typename U3, typename U4,
typename T1, typename T2, typename T3, typename T4>
static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4);
/**
* This method is thread-safe: it can be called from any thread.
@@ -443,12 +448,12 @@ public:
*/
template <typename U1, typename U2, typename U3, typename U4, typename U5,
typename T1, typename T2, typename T3, typename T4, typename T5>
static void ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
static void ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
/** @} */
/**
* \name Schedule events (in the same context) to run now.
* @name Schedule events (in the same context) to run now.
*/
/** @{ */
/**
@@ -748,12 +753,12 @@ public:
static uint32_t GetContext (void);
/** \copydoc SimulatorImpl::Schedule */
static EventId Schedule (Time const &time, const Ptr<EventImpl> &event);
static EventId Schedule (Time const &delay, const Ptr<EventImpl> &event);
/** \copydoc SimulatorImpl::ScheduleWithContext
* This method is thread-safe: it can be called from any thread.
*/
static void ScheduleWithContext (uint32_t context, const Time &time, EventImpl *event);
static void ScheduleWithContext (uint32_t context, const Time &delay, EventImpl *event);
/** \copydoc SimulatorImpl::ScheduleDestroy */
static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
@@ -776,7 +781,7 @@ private:
* \param [in] event The event to execute.
* \return The EventId.
*/
static EventId DoSchedule (Time const &time, EventImpl *event);
static EventId DoSchedule (Time const &delay, EventImpl *event);
/**
* Implementation of the various ScheduleNow methods.
* \param [in] event The event to execute.
@@ -816,160 +821,162 @@ Time Now (void);
namespace ns3 {
template <typename MEM, typename OBJ>
EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj)
EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj)
{
return DoSchedule (time, MakeEvent (mem_ptr, obj));
return DoSchedule (delay, MakeEvent (mem_ptr, obj));
}
template <typename MEM, typename OBJ,
typename T1>
EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1)
EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
{
return DoSchedule (time, MakeEvent (mem_ptr, obj, a1));
return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1));
}
template <typename MEM, typename OBJ,
typename T1, typename T2>
EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
{
return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2));
return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2));
}
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3>
EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
{
return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3));
return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
}
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4>
EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
{
return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
}
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4, typename T5>
EventId Simulator::Schedule (Time const &time, MEM mem_ptr, OBJ obj,
EventId Simulator::Schedule (Time const &delay, MEM mem_ptr, OBJ obj,
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
return DoSchedule (time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
return DoSchedule (delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
}
template <typename U1, typename T1>
EventId Simulator::Schedule (Time const &time, void (*f)(U1), T1 a1)
template <typename U1,
typename T1>
EventId Simulator::Schedule (Time const &delay, void (*f)(U1), T1 a1)
{
return DoSchedule (time, MakeEvent (f, a1));
return DoSchedule (delay, MakeEvent (f, a1));
}
template <typename U1, typename U2,
typename T1, typename T2>
EventId Simulator::Schedule (Time const &time, void (*f)(U1,U2), T1 a1, T2 a2)
EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
{
return DoSchedule (time, MakeEvent (f, a1, a2));
return DoSchedule (delay, MakeEvent (f, a1, a2));
}
template <typename U1, typename U2, typename U3,
typename T1, typename T2, typename T3>
EventId Simulator::Schedule (Time const &time, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
{
return DoSchedule (time, MakeEvent (f, a1, a2, a3));
return DoSchedule (delay, MakeEvent (f, a1, a2, a3));
}
template <typename U1, typename U2, typename U3, typename U4,
typename T1, typename T2, typename T3, typename T4>
EventId Simulator::Schedule (Time const &time, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
{
return DoSchedule (time, MakeEvent (f, a1, a2, a3, a4));
return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4));
}
template <typename U1, typename U2, typename U3, typename U4, typename U5,
typename T1, typename T2, typename T3, typename T4, typename T5>
EventId Simulator::Schedule (Time const &time, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
EventId Simulator::Schedule (Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
return DoSchedule (time, MakeEvent (f, a1, a2, a3, a4, a5));
return DoSchedule (delay, MakeEvent (f, a1, a2, a3, a4, a5));
}
template <typename MEM, typename OBJ>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
{
ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj));
ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj));
}
template <typename MEM, typename OBJ,
typename T1>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1)
{
return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1));
return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1));
}
template <typename MEM, typename OBJ,
typename T1, typename T2>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2)
{
return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2));
return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2));
}
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3)
{
return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3));
return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3));
}
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4)
{
return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4));
}
template <typename MEM, typename OBJ,
typename T1, typename T2, typename T3, typename T4, typename T5>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, MEM mem_ptr, OBJ obj,
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj,
T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
return ScheduleWithContext (context, time, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
return ScheduleWithContext (context, delay, MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5));
}
template <typename U1, typename T1>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1), T1 a1)
template <typename U1,
typename T1>
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1), T1 a1)
{
return ScheduleWithContext (context, time, MakeEvent (f, a1));
return ScheduleWithContext (context, delay, MakeEvent (f, a1));
}
template <typename U1, typename U2,
typename T1, typename T2>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2), T1 a1, T2 a2)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2), T1 a1, T2 a2)
{
return ScheduleWithContext (context, time, MakeEvent (f, a1, a2));
return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2));
}
template <typename U1, typename U2, typename U3,
typename T1, typename T2, typename T3>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3), T1 a1, T2 a2, T3 a3)
{
return ScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3));
return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3));
}
template <typename U1, typename U2, typename U3, typename U4,
typename T1, typename T2, typename T3, typename T4>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4)
{
return ScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4));
return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4));
}
template <typename U1, typename U2, typename U3, typename U4, typename U5,
typename T1, typename T2, typename T3, typename T4, typename T5>
void Simulator::ScheduleWithContext (uint32_t context, Time const &time, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
void Simulator::ScheduleWithContext (uint32_t context, Time const &delay, void (*f)(U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
{
return ScheduleWithContext (context, time, MakeEvent (f, a1, a2, a3, a4, a5));
return ScheduleWithContext (context, delay, MakeEvent (f, a1, a2, a3, a4, a5));
}
+9 -9
View File
@@ -462,22 +462,22 @@ DistributedSimulatorImpl::Stop (void)
}
void
DistributedSimulatorImpl::Stop (Time const &time)
DistributedSimulatorImpl::Stop (Time const &delay)
{
NS_LOG_FUNCTION (this << time.GetTimeStep ());
NS_LOG_FUNCTION (this << delay.GetTimeStep ());
Simulator::Schedule (time, &Simulator::Stop);
Simulator::Schedule (delay, &Simulator::Stop);
}
//
// Schedule an event for a _relative_ time in the future.
//
EventId
DistributedSimulatorImpl::Schedule (Time const &time, EventImpl *event)
DistributedSimulatorImpl::Schedule (Time const &delay, EventImpl *event)
{
NS_LOG_FUNCTION (this << time.GetTimeStep () << event);
NS_LOG_FUNCTION (this << delay.GetTimeStep () << event);
Time tAbsolute = time + TimeStep (m_currentTs);
Time tAbsolute = delay + TimeStep (m_currentTs);
NS_ASSERT (tAbsolute.IsPositive ());
NS_ASSERT (tAbsolute >= TimeStep (m_currentTs));
@@ -493,13 +493,13 @@ DistributedSimulatorImpl::Schedule (Time const &time, EventImpl *event)
}
void
DistributedSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event)
DistributedSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event)
{
NS_LOG_FUNCTION (this << context << time.GetTimeStep () << m_currentTs << event);
NS_LOG_FUNCTION (this << context << delay.GetTimeStep () << m_currentTs << event);
Scheduler::Event ev;
ev.impl = event;
ev.key.m_ts = m_currentTs + time.GetTimeStep ();
ev.key.m_ts = m_currentTs + delay.GetTimeStep ();
ev.key.m_context = context;
ev.key.m_uid = m_uid;
m_uid++;
+3 -3
View File
@@ -110,9 +110,9 @@ public:
virtual void Destroy ();
virtual bool IsFinished (void) const;
virtual void Stop (void);
virtual void Stop (Time const &time);
virtual EventId Schedule (Time const &time, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
virtual void Stop (Time const &delay);
virtual EventId Schedule (Time const &delay, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event);
virtual EventId ScheduleNow (EventImpl *event);
virtual EventId ScheduleDestroy (EventImpl *event);
virtual void Remove (const EventId &id);
+13 -13
View File
@@ -266,9 +266,9 @@ NullMessageSimulatorImpl::ScheduleNullMessageEvent (Ptr<RemoteChannelBundle> bun
{
NS_LOG_FUNCTION (this << bundle);
Time time (m_schedulerTune * bundle->GetDelay ().GetTimeStep ());
Time delay (m_schedulerTune * bundle->GetDelay ().GetTimeStep ());
bundle->SetEventId (Simulator::Schedule (time, &NullMessageSimulatorImpl::NullMessageEventHandler,
bundle->SetEventId (Simulator::Schedule (delay, &NullMessageSimulatorImpl::NullMessageEventHandler,
this, PeekPointer(bundle)));
}
@@ -279,9 +279,9 @@ NullMessageSimulatorImpl::RescheduleNullMessageEvent (Ptr<RemoteChannelBundle> b
Simulator::Cancel (bundle->GetEventId ());
Time time (m_schedulerTune * bundle->GetDelay ().GetTimeStep ());
Time delay (m_schedulerTune * bundle->GetDelay ().GetTimeStep ());
bundle->SetEventId (Simulator::Schedule (time, &NullMessageSimulatorImpl::NullMessageEventHandler,
bundle->SetEventId (Simulator::Schedule (delay, &NullMessageSimulatorImpl::NullMessageEventHandler,
this, PeekPointer(bundle)));
}
@@ -389,22 +389,22 @@ NullMessageSimulatorImpl::Stop (void)
}
void
NullMessageSimulatorImpl::Stop (Time const &time)
NullMessageSimulatorImpl::Stop (Time const &delay)
{
NS_LOG_FUNCTION (this << time.GetTimeStep ());
NS_LOG_FUNCTION (this << delay.GetTimeStep ());
Simulator::Schedule (time, &Simulator::Stop);
Simulator::Schedule (delay, &Simulator::Stop);
}
//
// Schedule an event for a _relative_ time in the future.
//
EventId
NullMessageSimulatorImpl::Schedule (Time const &time, EventImpl *event)
NullMessageSimulatorImpl::Schedule (Time const &delay, EventImpl *event)
{
NS_LOG_FUNCTION (this << time.GetTimeStep () << event);
NS_LOG_FUNCTION (this << delay.GetTimeStep () << event);
Time tAbsolute = time + TimeStep (m_currentTs);
Time tAbsolute = delay + TimeStep (m_currentTs);
NS_ASSERT (tAbsolute.IsPositive ());
NS_ASSERT (tAbsolute >= TimeStep (m_currentTs));
@@ -420,11 +420,11 @@ NullMessageSimulatorImpl::Schedule (Time const &time, EventImpl *event)
}
void
NullMessageSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event)
NullMessageSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event)
{
NS_LOG_FUNCTION (this << context << time.GetTimeStep () << m_currentTs << event);
NS_LOG_FUNCTION (this << context << delay.GetTimeStep () << m_currentTs << event);
Time tAbsolute(m_currentTs + time.GetTimeStep ());
Time tAbsolute(m_currentTs + delay.GetTimeStep ());
NS_ASSERT (tAbsolute.IsPositive ());
NS_ASSERT (tAbsolute >= TimeStep (m_currentTs));
+3 -3
View File
@@ -55,9 +55,9 @@ public:
virtual void Destroy ();
virtual bool IsFinished (void) const;
virtual void Stop (void);
virtual void Stop (Time const &time);
virtual EventId Schedule (Time const &time, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
virtual void Stop (Time const &delay);
virtual EventId Schedule (Time const &delay, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event);
virtual EventId ScheduleNow (EventImpl *event);
virtual EventId ScheduleDestroy (EventImpl *event);
virtual void Remove (const EventId &id);
@@ -141,24 +141,24 @@ VisualSimulatorImpl::Stop (void)
}
void
VisualSimulatorImpl::Stop (Time const &time)
VisualSimulatorImpl::Stop (Time const &delay)
{
m_simulator->Stop (time);
m_simulator->Stop (delay);
}
//
// Schedule an event for a _relative_ time in the future.
//
EventId
VisualSimulatorImpl::Schedule (Time const &time, EventImpl *event)
VisualSimulatorImpl::Schedule (Time const &delay, EventImpl *event)
{
return m_simulator->Schedule (time, event);
return m_simulator->Schedule (delay, event);
}
void
VisualSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event)
VisualSimulatorImpl::ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event)
{
m_simulator->ScheduleWithContext (context, time, event);
m_simulator->ScheduleWithContext (context, delay, event);
}
EventId
+3 -3
View File
@@ -52,9 +52,9 @@ public:
virtual void Destroy ();
virtual bool IsFinished (void) const;
virtual void Stop (void);
virtual void Stop (Time const &time);
virtual EventId Schedule (Time const &time, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &time, EventImpl *event);
virtual void Stop (Time const &delay);
virtual EventId Schedule (Time const &delay, EventImpl *event);
virtual void ScheduleWithContext (uint32_t context, Time const &delay, EventImpl *event);
virtual EventId ScheduleNow (EventImpl *event);
virtual EventId ScheduleDestroy (EventImpl *event);
virtual void Remove (const EventId &id);