make Time relative instead of Absolute
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 21 Nov 2006 15:50:09 +0100
changeset 162 5b398ac221c7
parent 161 c3aee00484fc
child 163 2a7e05018eeb
make Time relative instead of Absolute
samples/main-simulator.cc
src/simulator/nstime.h
src/simulator/simulator.cc
utils/bench-simulator.cc
--- a/samples/main-simulator.cc	Fri Nov 03 11:07:24 2006 +0100
+++ b/samples/main-simulator.cc	Tue Nov 21 15:50:09 2006 +0100
@@ -15,7 +15,7 @@
 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 @@
 {
   MyModel model;
 
-  Simulator::Schedule (Now () + Seconds (10.0), &random_function, &model);
+  Simulator::Schedule (Seconds (10.0), &random_function, &model);
 
   Simulator::Run ();
 
--- a/src/simulator/nstime.h	Fri Nov 03 11:07:24 2006 +0100
+++ b/src/simulator/nstime.h	Tue Nov 21 15:50:09 2006 +0100
@@ -331,7 +331,7 @@
  * 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 @@
  * 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 @@
  * 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 @@
  * 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 @@
  * 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
--- a/src/simulator/simulator.cc	Fri Nov 03 11:07:24 2006 +0100
+++ b/src/simulator/simulator.cc	Tue Nov 21 15:50:09 2006 +0100
@@ -394,7 +394,7 @@
 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 @@
       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 @@
   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 ();
--- a/utils/bench-simulator.cc	Fri Nov 03 11:07:24 2006 +0100
+++ b/utils/bench-simulator.cc	Tue Nov 21 15:50:09 2006 +0100
@@ -73,7 +73,7 @@
   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 @@
   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++;
 }