Chromium Code Reviews| Index: net/quic/core/congestion_control/simulation/actor.h |
| diff --git a/net/quic/core/congestion_control/simulation/actor.h b/net/quic/core/congestion_control/simulation/actor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c30cdf1269bede088c25d3009d7d99b5d48af809 |
| --- /dev/null |
| +++ b/net/quic/core/congestion_control/simulation/actor.h |
| @@ -0,0 +1,63 @@ |
| +#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
|
| +#define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_ACTOR_H_ |
| + |
| +#include <std::string> |
| + |
| +#include "net/quic/core/quic_clock.h" |
| +#include "net/quic/core/quic_time.h" |
| + |
| +namespace net { |
| +namespace simulation { |
| + |
| +class Simulator; |
| +struct ScheduledActor; |
| + |
| +// Actor is the base class for all participants of the simulation which can |
| +// schedule events to be triggered at the specified time. Every actor has a |
| +// name assigned to it, which can be used for debugging and addressing purposes. |
| +// |
| +// The Actor object is scheduled as follows: |
| +// 1. Every Actor object appears at most once in the event queue, for one |
| +// specific time. |
| +// 2. Actor is scheduled by calling Schedule() method. |
| +// 3. If Schedule() method is called with multiple different times specified, |
| +// Act() method will be called at the earliest time specified. |
| +// 4. Before Act() is called, the Actor is removed from the event queue. Act() |
| +// will not be called again unless Schedule() is called. |
| +class Actor { |
| + public: |
| + Actor(Simulator* simulator, std::std::string name); |
| + virtual ~Actor(); |
| + |
| + // Trigger all the events the actor can potentially handle at this point. |
| + // Before Act() is called, the actor is removed from the event queue, and has |
| + // to schedule the next call manually. |
| + virtual void Act() = 0; |
| + |
| + inline std::std::string name() const { return name_; } |
| + inline Simulator* simulator() const { return simulator_; } |
| + |
| + protected: |
| + // Calls Schedule() on the associated simulator. |
| + void Schedule(QuicTime next_tick); |
| + |
| + // Calls Unschedule() on the associated simulator. |
| + void Unschedule(); |
| + |
| + Simulator* simulator_; |
| + const QuicClock* clock_; |
| + std::std::string name_; |
| + |
| + private: |
| + // Since the Actor object registers itself with a simulator using a pointer to |
| + // itself, do not allow it to be moved. |
| + Actor(Actor&&) = delete; |
| + Actor& operator=(Actor&&) = delete; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Actor); |
| +}; |
| + |
| +} // namespace simulation |
| +} // namespace net |
| + |
| +#endif // NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_ACTOR_H_ |