src/simulator/timer.h
changeset 1691 d717c61ae738
parent 1689 c52eb7e20762
child 1692 b35ba80cafef
equal deleted inserted replaced
1690:16b198d63c1e 1691:d717c61ae738
   189   /**
   189   /**
   190    * \return true if there is a currently-running event, false otherwise.
   190    * \return true if there is a currently-running event, false otherwise.
   191    */
   191    */
   192   bool IsRunning (void) const;
   192   bool IsRunning (void) const;
   193   /**
   193   /**
       
   194    * \returns true if this timer was suspended and not yet resumed, false
       
   195    *          otherwise.
       
   196    */
       
   197   bool IsSuspended (void) const;
       
   198   /**
   194    * Schedule a new event using the currently-configured delay, function, 
   199    * Schedule a new event using the currently-configured delay, function, 
   195    * and arguments.
   200    * and arguments.
   196    */
   201    */
   197   void Schedule (void);
   202   void Schedule (void);
   198   /**
   203   /**
   200    *
   205    *
   201    * Schedule a new event using the specified delay (ignore the delay set by 
   206    * Schedule a new event using the specified delay (ignore the delay set by 
   202    * Timer::SetDelay), function, and arguments.
   207    * Timer::SetDelay), function, and arguments.
   203    */
   208    */
   204   void Schedule (Time delay);
   209   void Schedule (Time delay);
       
   210 
       
   211   /**
       
   212    * Cancel the timer and save the amount of time left until it was
       
   213    * set to expire.
       
   214    * Calling Suspend on a non-running timer is an error.
       
   215    */
       
   216   void Suspend (void);
       
   217   /**
       
   218    * Restart the timer to expire within the amount of time left saved
       
   219    * during Suspend.
       
   220    * Calling Resume without a prior call to Suspend is an error.
       
   221    */
       
   222   void Resume (void);
   205 
   223 
   206 private:
   224 private:
   207   template <typename FN>
   225   template <typename FN>
   208   void DoSetFunction (IntToType<0>, FN fn);
   226   void DoSetFunction (IntToType<0>, FN fn);
   209   template <typename FN>
   227   template <typename FN>
   232   template <typename MEM_PTR, typename OBJ_PTR>
   250   template <typename MEM_PTR, typename OBJ_PTR>
   233   void DoSetFunction (IntToType<5>, MEM_PTR memPtr, OBJ_PTR objPtr);
   251   void DoSetFunction (IntToType<5>, MEM_PTR memPtr, OBJ_PTR objPtr);
   234   template <typename MEM_PTR, typename OBJ_PTR>
   252   template <typename MEM_PTR, typename OBJ_PTR>
   235   void DoSetFunction (IntToType<6>, MEM_PTR memPtr, OBJ_PTR objPtr);
   253   void DoSetFunction (IntToType<6>, MEM_PTR memPtr, OBJ_PTR objPtr);
   236 
   254 
       
   255   enum {
       
   256     TIMER_SUSPENDED = (1<<7)
       
   257   };
       
   258 
   237   int m_flags;
   259   int m_flags;
   238   Time m_delay;
   260   Time m_delay;
   239   EventId m_event;
   261   EventId m_event;
   240   TimerImpl *m_impl;
   262   TimerImpl *m_impl;
       
   263   Time m_delayLeft;
   241 };
   264 };
   242 
   265 
   243 } // namespace ns3
   266 } // namespace ns3
   244 
   267 
   245 
   268