testers: Refactor some Event subclasses to lambdas
authorSean Wilson <spwilson2@wisc.edu>
Wed, 28 Jun 2017 15:44:34 +0000 (10:44 -0500)
committerSean Wilson <spwilson2@wisc.edu>
Wed, 12 Jul 2017 20:07:05 +0000 (20:07 +0000)
Change-Id: I897b6162a827216b7bad74d955c0e50e06a5a3ec
Signed-off-by: Sean Wilson <spwilson2@wisc.edu>
Reviewed-on: https://gem5-review.googlesource.com/3926
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/cpu/testers/directedtest/RubyDirectedTester.cc
src/cpu/testers/directedtest/RubyDirectedTester.hh
src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.cc
src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.hh
src/cpu/testers/rubytest/RubyTester.cc
src/cpu/testers/rubytest/RubyTester.hh

index 667d50ffda15807b9bf1954244439fe348dbcdb5..ef133379de69732e99f22ef16e6446527e87e196 100644 (file)
@@ -47,7 +47,9 @@
 #include "sim/sim_exit.hh"
 
 RubyDirectedTester::RubyDirectedTester(const Params *p)
-  : MemObject(p), directedStartEvent(this),
+  : MemObject(p),
+    directedStartEvent([this]{ wakeup(); }, "Directed tick",
+                       false, Event::CPU_Tick_Pri),
     m_requests_to_complete(p->requests_to_complete),
     generator(p->generator)
 {
index 74a89117864fe743bdca0469578d973dd19f761f..00278a65e420889725e5e2a70571329c4e9b1b2c 100644 (file)
@@ -85,20 +85,7 @@ class RubyDirectedTester : public MemObject
     void print(std::ostream& out) const;
 
   protected:
-    class DirectedStartEvent : public Event
-    {
-      private:
-        RubyDirectedTester *tester;
-
-      public:
-        DirectedStartEvent(RubyDirectedTester *_tester)
-            : Event(CPU_Tick_Pri), tester(_tester)
-        {}
-        void process() { tester->wakeup(); }
-        virtual const char *description() const { return "Directed tick"; }
-    };
-
-    DirectedStartEvent directedStartEvent;
+    EventFunctionWrapper directedStartEvent;
 
   private:
     void hitCallback(NodeID proc, Addr addr);
index 0f8c877292ea8b31babd55845451fba951694d51..1345fe93e34a028cea0dad8371df316be1f9d464 100644 (file)
@@ -76,7 +76,8 @@ GarnetSyntheticTraffic::sendPkt(PacketPtr pkt)
 
 GarnetSyntheticTraffic::GarnetSyntheticTraffic(const Params *p)
     : MemObject(p),
-      tickEvent(this),
+      tickEvent([this]{ tick(); }, "GarnetSyntheticTraffic tick",
+                false, Event::CPU_Tick_Pri),
       cachePort("GarnetSyntheticTraffic", this),
       retryPkt(NULL),
       size(p->memory_size),
index 94eee44d7aa79f54fd9082c84986b1a085093bc0..3da7e27742d46199fd6dce635923fae74223e5a2 100644 (file)
@@ -74,21 +74,7 @@ class GarnetSyntheticTraffic : public MemObject
     void printAddr(Addr a);
 
   protected:
-    class TickEvent : public Event
-    {
-      private:
-        GarnetSyntheticTraffic *cpu;
-
-      public:
-        TickEvent(GarnetSyntheticTraffic *c) : Event(CPU_Tick_Pri), cpu(c) {}
-        void process() { cpu->tick(); }
-        virtual const char *description() const
-        {
-            return "GarnetSyntheticTraffic tick";
-        }
-    };
-
-    TickEvent tickEvent;
+    EventFunctionWrapper tickEvent;
 
     class CpuPort : public MasterPort
     {
@@ -160,6 +146,3 @@ class GarnetSyntheticTraffic : public MemObject
 };
 
 #endif // __CPU_GARNET_SYNTHETIC_TRAFFIC_HH__
-
-
-
index baf2b7e5bf84062bc5932361b73a5d953a3a17a5..712d15dfff3a96c48e2461d2d068dd1e23434ef8 100644 (file)
@@ -50,7 +50,9 @@
 #include "sim/system.hh"
 
 RubyTester::RubyTester(const Params *p)
-  : MemObject(p), checkStartEvent(this),
+  : MemObject(p),
+    checkStartEvent([this]{ wakeup(); }, "RubyTester tick",
+                    false, Event::CPU_Tick_Pri),
     _masterId(p->system->getMasterId(name())),
     m_checkTable_ptr(nullptr),
     m_num_cpus(p->num_cpus),
index 39e6d78a323cc29a2a4391a59a622f021f59e4d1..007035977574255b1e63d182227649b37008a1f1 100644 (file)
@@ -118,20 +118,7 @@ class RubyTester : public MemObject
 
     MasterID masterId() { return _masterId; }
   protected:
-    class CheckStartEvent : public Event
-    {
-      private:
-        RubyTester *tester;
-
-      public:
-        CheckStartEvent(RubyTester *_tester)
-            : Event(CPU_Tick_Pri), tester(_tester)
-        {}
-        void process() { tester->wakeup(); }
-        virtual const char *description() const { return "RubyTester tick"; }
-    };
-
-    CheckStartEvent checkStartEvent;
+    EventFunctionWrapper checkStartEvent;
 
     MasterID _masterId;