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