Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #ifndef NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_ACTOR_H_ | |
|
Ryan Hamilton
2016/09/08 21:45:45
I think you need to add the chrome license to each
| |
| 2 #define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_ACTOR_H_ | |
| 3 | |
| 4 #include <std::string> | |
| 5 | |
| 6 #include "net/quic/core/quic_clock.h" | |
| 7 #include "net/quic/core/quic_time.h" | |
| 8 | |
| 9 namespace net { | |
| 10 namespace simulation { | |
| 11 | |
| 12 class Simulator; | |
| 13 struct ScheduledActor; | |
| 14 | |
| 15 // Actor is the base class for all participants of the simulation which can | |
| 16 // schedule events to be triggered at the specified time. Every actor has a | |
| 17 // name assigned to it, which can be used for debugging and addressing purposes. | |
| 18 // | |
| 19 // The Actor object is scheduled as follows: | |
| 20 // 1. Every Actor object appears at most once in the event queue, for one | |
| 21 // specific time. | |
| 22 // 2. Actor is scheduled by calling Schedule() method. | |
| 23 // 3. If Schedule() method is called with multiple different times specified, | |
| 24 // Act() method will be called at the earliest time specified. | |
| 25 // 4. Before Act() is called, the Actor is removed from the event queue. Act() | |
| 26 // will not be called again unless Schedule() is called. | |
| 27 class Actor { | |
| 28 public: | |
| 29 Actor(Simulator* simulator, std::std::string name); | |
| 30 virtual ~Actor(); | |
| 31 | |
| 32 // Trigger all the events the actor can potentially handle at this point. | |
| 33 // Before Act() is called, the actor is removed from the event queue, and has | |
| 34 // to schedule the next call manually. | |
| 35 virtual void Act() = 0; | |
| 36 | |
| 37 inline std::std::string name() const { return name_; } | |
| 38 inline Simulator* simulator() const { return simulator_; } | |
| 39 | |
| 40 protected: | |
| 41 // Calls Schedule() on the associated simulator. | |
| 42 void Schedule(QuicTime next_tick); | |
| 43 | |
| 44 // Calls Unschedule() on the associated simulator. | |
| 45 void Unschedule(); | |
| 46 | |
| 47 Simulator* simulator_; | |
| 48 const QuicClock* clock_; | |
| 49 std::std::string name_; | |
| 50 | |
| 51 private: | |
| 52 // Since the Actor object registers itself with a simulator using a pointer to | |
| 53 // itself, do not allow it to be moved. | |
| 54 Actor(Actor&&) = delete; | |
| 55 Actor& operator=(Actor&&) = delete; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(Actor); | |
| 58 }; | |
| 59 | |
| 60 } // namespace simulation | |
| 61 } // namespace net | |
| 62 | |
| 63 #endif // NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_ACTOR_H_ | |
| OLD | NEW |