Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1439)

Unified Diff: net/quic/core/congestion_control/simulation/actor.h

Issue 2322233004: Landing Recent QUIC changes until Sun Sep 4 03:41:00 (Closed)
Patch Set: Remove simulation files from the build. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7c84d6c57712dd547546bb1fc16d60a0ae5f5ac3
--- /dev/null
+++ b/net/quic/core/congestion_control/simulation/actor.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_ACTOR_H_
+#define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_ACTOR_H_
+
+#include <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::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::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::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_
« no previous file with comments | « net/quic/core/congestion_control/simulation/README.md ('k') | net/quic/core/congestion_control/simulation/actor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698