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

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