make Time relative instead of Absolute
This commit is contained in:
@@ -15,7 +15,7 @@ private:
|
||||
void
|
||||
MyModel::Start (void)
|
||||
{
|
||||
Simulator::Schedule (Now () + Seconds (10.0),
|
||||
Simulator::Schedule (Seconds (10.0),
|
||||
&MyModel::DealWithEvent,
|
||||
this, Simulator::Now ().ApproximateToSeconds ());
|
||||
}
|
||||
@@ -39,7 +39,7 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
MyModel model;
|
||||
|
||||
Simulator::Schedule (Now () + Seconds (10.0), &random_function, &model);
|
||||
Simulator::Schedule (Seconds (10.0), &random_function, &model);
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ public:
|
||||
* For example:
|
||||
* \code
|
||||
* Time t = Seconds (2.0);
|
||||
* Simulator::Schedule (Now () + NanoSeconds (5.0), ...);
|
||||
* Simulator::Schedule (NanoSeconds (5.0), ...);
|
||||
* \endcode
|
||||
*/
|
||||
class Seconds : public TimeUnit<1>
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
* For example:
|
||||
* \code
|
||||
* Time t = MilliSeconds (2);
|
||||
* Simulator::Schedule (Now () + MilliSeconds (5), ...);
|
||||
* Simulator::Schedule (MilliSeconds (5), ...);
|
||||
* \endcode
|
||||
*/
|
||||
class MilliSeconds : public TimeUnit<1>
|
||||
@@ -362,7 +362,7 @@ public:
|
||||
* For example:
|
||||
* \code
|
||||
* Time t = MicroSeconds (2);
|
||||
* Simulator::Schedule (Now () + MicroSeconds (5), ...);
|
||||
* Simulator::Schedule (MicroSeconds (5), ...);
|
||||
* \endcode
|
||||
*/
|
||||
class MicroSeconds : public TimeUnit<1>
|
||||
@@ -377,7 +377,7 @@ public:
|
||||
* For example:
|
||||
* \code
|
||||
* Time t = NanoSeconds (2);
|
||||
* Simulator::Schedule (Now () + NanoSeconds (5), ...);
|
||||
* Simulator::Schedule (NanoSeconds (5), ...);
|
||||
* \endcode
|
||||
*/
|
||||
class NanoSeconds : public TimeUnit<1>
|
||||
@@ -395,7 +395,7 @@ public:
|
||||
* It is typically used as shown below to schedule an event
|
||||
* which expires in 2 seconds from now:
|
||||
* \code
|
||||
* Simulator::Schedule (Now () + Seconds (2.0), &my_function);
|
||||
* Simulator::Schedule (Seconds (2.0), &my_function);
|
||||
* \endcode
|
||||
*/
|
||||
class Now : public Time
|
||||
|
||||
@@ -394,7 +394,7 @@ Simulator::MakeEvent (void (*f) (void))
|
||||
EventId
|
||||
Simulator::Schedule (Time const &time, EventImpl *ev)
|
||||
{
|
||||
return GetPriv ()->Schedule (time, ev);
|
||||
return GetPriv ()->Schedule (Now () + time, ev);
|
||||
}
|
||||
void
|
||||
Simulator::ScheduleNow (EventImpl *ev)
|
||||
@@ -517,7 +517,7 @@ SimulatorTests::B (int b)
|
||||
m_b = true;
|
||||
}
|
||||
Simulator::Remove (m_idC);
|
||||
Simulator::Schedule (Now () + MicroSeconds (10), &SimulatorTests::D, this, 4);
|
||||
Simulator::Schedule (MicroSeconds (10), &SimulatorTests::D, this, 4);
|
||||
}
|
||||
void
|
||||
SimulatorTests::C (int c)
|
||||
@@ -564,9 +564,9 @@ SimulatorTests::RunOneTest (void)
|
||||
m_c = true;
|
||||
m_d = false;
|
||||
|
||||
EventId a = Simulator::Schedule (Now () + MicroSeconds (10), &SimulatorTests::A, this, 1);
|
||||
Simulator::Schedule (Now () + MicroSeconds (11), &SimulatorTests::B, this, 2);
|
||||
m_idC = Simulator::Schedule (Now () + MicroSeconds (12), &SimulatorTests::C, this, 3);
|
||||
EventId a = Simulator::Schedule (MicroSeconds (10), &SimulatorTests::A, this, 1);
|
||||
Simulator::Schedule (MicroSeconds (11), &SimulatorTests::B, this, 2);
|
||||
m_idC = Simulator::Schedule (MicroSeconds (12), &SimulatorTests::C, this, 3);
|
||||
|
||||
Simulator::Cancel (a);
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -73,7 +73,7 @@ Bench::RunBench (void)
|
||||
time.Start ();
|
||||
for (std::vector<uint64_t>::const_iterator i = m_distribution.begin ();
|
||||
i != m_distribution.end (); i++) {
|
||||
Simulator::Schedule (Now () + NanoSeconds (*i), &Bench::Cb, this);
|
||||
Simulator::Schedule (NanoSeconds (*i), &Bench::Cb, this);
|
||||
}
|
||||
init = time.End ();
|
||||
|
||||
@@ -105,7 +105,7 @@ Bench::Cb (void)
|
||||
if (gDebug) {
|
||||
std::cerr << "event at " << Simulator::Now ().ApproximateToSeconds () << "s" << std::endl;
|
||||
}
|
||||
Simulator::Schedule (Now () + NanoSeconds (*m_current), &Bench::Cb, this);
|
||||
Simulator::Schedule (NanoSeconds (*m_current), &Bench::Cb, this);
|
||||
m_current++;
|
||||
m_n++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user