OLD | NEW |
(Empty) | |
| 1 #ifndef NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_QUEUE_H_ |
| 2 #define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_QUEUE_H_ |
| 3 |
| 4 #include "net/quic/core/congestion_control/simulation/link.h" |
| 5 |
| 6 namespace net { |
| 7 namespace simulation { |
| 8 |
| 9 // A finitely sized queue which egresses packets onto a constrained link. The |
| 10 // capacity of the queue is measured in bytes as opposed to packets. |
| 11 class Queue : public Actor, public UnconstrainedPortInterface { |
| 12 public: |
| 13 class ListenerInterface { |
| 14 public: |
| 15 virtual ~ListenerInterface(); |
| 16 |
| 17 // Called whenever a packet is removed from the queue. |
| 18 virtual void OnPacketDequeued() = 0; |
| 19 }; |
| 20 |
| 21 Queue(Simulator* simulator, std::std::string name, QuicByteCount capacity); |
| 22 |
| 23 void set_tx_port(ConstrainedPortInterface* port); |
| 24 |
| 25 void AcceptPacket(std::unique_ptr<Packet> packet) override; |
| 26 |
| 27 void Act() override; |
| 28 |
| 29 inline QuicByteCount capacity() const { return capacity_; } |
| 30 inline QuicByteCount bytes_queued() const { return bytes_queued_; } |
| 31 inline QuicPacketCount packets_queued() const { return queue_.size(); } |
| 32 |
| 33 inline void set_listener_interface(ListenerInterface* std::listener) { |
| 34 std::listener_ = std::listener; |
| 35 } |
| 36 |
| 37 private: |
| 38 void ScheduleNextPacketDequeue(); |
| 39 |
| 40 const QuicByteCount capacity_; |
| 41 QuicByteCount bytes_queued_; |
| 42 |
| 43 ConstrainedPortInterface* tx_port_; |
| 44 std::queue<std::unique_ptr<Packet>> queue_; |
| 45 |
| 46 ListenerInterface* std::listener_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(Queue); |
| 49 }; |
| 50 |
| 51 } // namespace simulation |
| 52 } // namespace net |
| 53 |
| 54 #endif // NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_QUEUE_H_ |
OLD | NEW |