src/core/model/synchronizer.h
changeset 11531 5d6b3f94ebf3
parent 11131 6a448ac28669
child 11538 397bd6465dd9
equal deleted inserted replaced
11530:65ddfcaae79a 11531:5d6b3f94ebf3
    22 #include <stdint.h>
    22 #include <stdint.h>
    23 #include "nstime.h"
    23 #include "nstime.h"
    24 #include "object.h"
    24 #include "object.h"
    25 
    25 
    26 /**
    26 /**
    27  * \file
    27  * @file
    28  * \ingroup realtime
    28  * @ingroup realtime
    29  * ns3::Synchronizer declaration.
    29  * ns3::Synchronizer declaration.
    30  */
    30  */
    31 
    31 
    32 namespace ns3 {
    32 namespace ns3 {
    33 
    33 
    51 class Synchronizer : public Object 
    51 class Synchronizer : public Object 
    52 {
    52 {
    53 public:
    53 public:
    54   /**
    54   /**
    55    * Get the registered TypeId for this class.
    55    * Get the registered TypeId for this class.
    56    * \returns The TypeId.
    56    * @returns The TypeId.
    57    */
    57    */
    58   static TypeId GetTypeId (void);
    58   static TypeId GetTypeId (void);
    59 
    59 
    60   /** Constructor. */
    60   /** Constructor. */
    61   Synchronizer ();
    61   Synchronizer ();
    66    * @brief Return true if this synchronizer is actually synchronizing to a
    66    * @brief Return true if this synchronizer is actually synchronizing to a
    67    * realtime clock.
    67    * realtime clock.
    68    *
    68    *
    69    * The simulator sometimes needs to know this.
    69    * The simulator sometimes needs to know this.
    70    *
    70    *
    71    * @returns \c true if locked with realtime, \c false if not.
    71    * @returns @c true if locked with realtime, @c false if not.
    72    */
    72    */
    73   bool Realtime (void);
    73   bool Realtime (void);
    74 
    74 
    75   /**
    75   /**
    76    * @brief Retrieve the value of the origin of the underlying normalized wall
    76    * @brief Retrieve the value of the origin of the underlying normalized wall
   125 
   125 
   126   /**
   126   /**
   127    * @brief Wait until the real time is in sync with the specified simulation
   127    * @brief Wait until the real time is in sync with the specified simulation
   128    * time or until the synchronizer is Sigalled.
   128    * time or until the synchronizer is Sigalled.
   129    *
   129    *
   130    * This is where the real work of synchronization is done.  The \c tsCurrent
   130    * This is where the real work of synchronization is done.  The @c tsCurrent
   131    * argument is the simulation time.  The job of Synchronize is to
   131    * argument is the simulation time.  The job of Synchronize is to
   132    * translate from simulation time to synchronizer time (in a perfect world
   132    * translate from simulation time to synchronizer time (in a perfect world
   133    * this is the same time) and then figure out how long in real-time it needs
   133    * this is the same time) and then figure out how long in real-time it needs
   134    * to wait until that synchronizer / simulation time comes around.
   134    * to wait until that synchronizer / simulation time comes around.
   135    *
   135    *
   139    * requested simulation time.
   139    * requested simulation time.
   140    *
   140    *
   141    * @param tsCurrent The current simulation time (in Time resolution units).
   141    * @param tsCurrent The current simulation time (in Time resolution units).
   142    * @param tsDelay The simulation time we need to wait for (in Time
   142    * @param tsDelay The simulation time we need to wait for (in Time
   143    *     resolution units).
   143    *     resolution units).
   144    * @returns \c true if the function ran to completion,
   144    * @returns @c true if the function ran to completion,
   145    *          \c false if it was interrupted by a Signal.
   145    *          @c false if it was interrupted by a Signal.
   146    * @see DoSynchronize
   146    * @see DoSynchronize
   147    * @see Signal
   147    * @see Signal
   148    */
   148    */
   149   bool Synchronize (uint64_t tsCurrent, uint64_t tsDelay);
   149   bool Synchronize (uint64_t tsCurrent, uint64_t tsDelay);
   150 
   150 
   217    * @see SetOrigin
   217    * @see SetOrigin
   218    */
   218    */
   219   virtual void DoSetOrigin (uint64_t ns) = 0;
   219   virtual void DoSetOrigin (uint64_t ns) = 0;
   220 
   220 
   221   /**
   221   /**
   222    * @brief Return \c true if this synchronizer is actually synchronizing to a
   222    * @brief Return @c true if this synchronizer is actually synchronizing to a
   223    * realtime clock.
   223    * realtime clock.
   224    *
   224    *
   225    * The simulator sometimes needs to know this.
   225    * The simulator sometimes needs to know this.
   226    *
   226    *
   227    * Subclasses are expected to implement this method to tell the outside world
   227    * Subclasses are expected to implement this method to tell the outside world
   228    * whether or not they are synchronizing to a realtime clock.
   228    * whether or not they are synchronizing to a realtime clock.
   229    *
   229    *
   230    * @returns \c true if locked with realtime, \c false if not.
   230    * @returns @c true if locked with realtime, @c false if not.
   231    */
   231    */
   232   virtual bool DoRealtime (void) = 0;
   232   virtual bool DoRealtime (void) = 0;
   233 
   233 
   234   /**
   234   /**
   235    * @brief Retrieve the value of the origin of the underlying normalized wall
   235    * @brief Retrieve the value of the origin of the underlying normalized wall
   246   /**
   246   /**
   247    * @brief Wait until the real time is in sync with the specified simulation
   247    * @brief Wait until the real time is in sync with the specified simulation
   248    * time.
   248    * time.
   249    *
   249    *
   250    * This is where the real work of synchronization is done.  The
   250    * This is where the real work of synchronization is done.  The
   251    * \c nsCurrent argument is the simulation time (in ns).  The job of
   251    * @c nsCurrent argument is the simulation time (in ns).  The job of
   252    * DoSynchronize is to translate from simulation time to synchronizer time
   252    * DoSynchronize is to translate from simulation time to synchronizer time
   253    * (in a perfect world these are the same time) and then figure out
   253    * (in a perfect world these are the same time) and then figure out
   254    * how long in real-time it needs to wait until that
   254    * how long in real-time it needs to wait until that
   255    * synchronizer / simulation time comes around.
   255    * synchronizer / simulation time comes around.
   256    *
   256    *
   259    * or some combination) until the requested simulation time.
   259    * or some combination) until the requested simulation time.
   260    *
   260    *
   261    * @param nsCurrent The current simulation time (in nanosecond units).
   261    * @param nsCurrent The current simulation time (in nanosecond units).
   262    * @param nsDelay The simulation time we need to wait for (normalized to 
   262    * @param nsDelay The simulation time we need to wait for (normalized to 
   263    * nanosecond units).
   263    * nanosecond units).
   264    * @returns \c true if the function ran to completion,
   264    * @returns @c true if the function ran to completion,
   265    *          \c false if it was interrupted by a Signal.
   265    *          @c false if it was interrupted by a Signal.
   266    * @see Synchronize
   266    * @see Synchronize
   267    * @see Signal
   267    * @see Signal
   268    */
   268    */
   269   virtual bool DoSynchronize (uint64_t nsCurrent, uint64_t nsDelay) = 0;
   269   virtual bool DoSynchronize (uint64_t nsCurrent, uint64_t nsDelay) = 0;
   270 
   270