From: Sean Wilson Date: Wed, 28 Jun 2017 15:44:34 +0000 (-0500) Subject: testers: Refactor some Event subclasses to lambdas X-Git-Tag: v19.0.0.0~2690 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=60adacb5716d91b9838fbb5e2b0d3e766c1cfdb1;p=gem5.git testers: Refactor some Event subclasses to lambdas Change-Id: I897b6162a827216b7bad74d955c0e50e06a5a3ec Signed-off-by: Sean Wilson Reviewed-on: https://gem5-review.googlesource.com/3926 Maintainer: Jason Lowe-Power Reviewed-by: Jason Lowe-Power --- diff --git a/src/cpu/testers/directedtest/RubyDirectedTester.cc b/src/cpu/testers/directedtest/RubyDirectedTester.cc index 667d50ffd..ef133379d 100644 --- a/src/cpu/testers/directedtest/RubyDirectedTester.cc +++ b/src/cpu/testers/directedtest/RubyDirectedTester.cc @@ -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) { diff --git a/src/cpu/testers/directedtest/RubyDirectedTester.hh b/src/cpu/testers/directedtest/RubyDirectedTester.hh index 74a891178..00278a65e 100644 --- a/src/cpu/testers/directedtest/RubyDirectedTester.hh +++ b/src/cpu/testers/directedtest/RubyDirectedTester.hh @@ -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); diff --git a/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.cc b/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.cc index 0f8c87729..1345fe93e 100644 --- a/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.cc +++ b/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.cc @@ -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), diff --git a/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.hh b/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.hh index 94eee44d7..3da7e2774 100644 --- a/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.hh +++ b/src/cpu/testers/garnet_synthetic_traffic/GarnetSyntheticTraffic.hh @@ -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__ - - - diff --git a/src/cpu/testers/rubytest/RubyTester.cc b/src/cpu/testers/rubytest/RubyTester.cc index baf2b7e5b..712d15dff 100644 --- a/src/cpu/testers/rubytest/RubyTester.cc +++ b/src/cpu/testers/rubytest/RubyTester.cc @@ -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), diff --git a/src/cpu/testers/rubytest/RubyTester.hh b/src/cpu/testers/rubytest/RubyTester.hh index 39e6d78a3..007035977 100644 --- a/src/cpu/testers/rubytest/RubyTester.hh +++ b/src/cpu/testers/rubytest/RubyTester.hh @@ -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;