From 55f70760de9cf9d16905372d885b7925722721a8 Mon Sep 17 00:00:00 2001 From: Sean Wilson Date: Tue, 27 Jun 2017 13:07:51 -0500 Subject: sim, gdb: Refactor some Event subclasses into lambdas Change-Id: If3e4329204f27eda96b50ec6ac279ebc6ef23d99 Signed-off-by: Sean Wilson Reviewed-on: https://gem5-review.googlesource.com/3921 Reviewed-by: Jason Lowe-Power Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg --- src/sim/ticked_object.cc | 12 +++++++++++- src/sim/ticked_object.hh | 35 +++++------------------------------ 2 files changed, 16 insertions(+), 31 deletions(-) (limited to 'src/sim') diff --git a/src/sim/ticked_object.cc b/src/sim/ticked_object.cc index a9f3aceb7..1a04dc14f 100644 --- a/src/sim/ticked_object.cc +++ b/src/sim/ticked_object.cc @@ -46,7 +46,7 @@ Ticked::Ticked(ClockedObject &object_, Stats::Scalar *imported_num_cycles, Event::Priority priority) : object(object_), - event(*this, priority), + event([this]{ processClockEvent(); }, name(), false, priority), running(false), lastStopped(0), /* Allocate numCycles if an external stat wasn't passed in */ @@ -55,6 +55,16 @@ Ticked::Ticked(ClockedObject &object_, *numCyclesLocal)) { } +void +Ticked::processClockEvent() { + ++tickCycles; + ++numCycles; + countCycles(Cycles(1)); + evaluate(); + if (running) + object.schedule(event, object.clockEdge(Cycles(1))); +} + void Ticked::regStats() { diff --git a/src/sim/ticked_object.hh b/src/sim/ticked_object.hh index 3ba0045fc..ad7d6e93b 100644 --- a/src/sim/ticked_object.hh +++ b/src/sim/ticked_object.hh @@ -60,39 +60,14 @@ class TickedObjectParams; class Ticked : public Serializable { protected: - /** An event to call process periodically */ - class ClockEvent : public Event - { - public: - Ticked &owner; - - ClockEvent(Ticked &owner_, Priority priority) : - Event(priority), - owner(owner_) - { } - - /** Evaluate and reschedule */ - void - process() - { - ++owner.tickCycles; - ++owner.numCycles; - owner.countCycles(Cycles(1)); - owner.evaluate(); - if (owner.running) { - owner.object.schedule(this, - owner.object.clockEdge(Cycles(1))); - } - } - }; - - friend class ClockEvent; - /** ClockedObject who is responsible for this Ticked's actions/stats */ ClockedObject &object; - /** The single instance of ClockEvent used */ - ClockEvent event; + /** The wrapper for processClockEvent */ + EventFunctionWrapper event; + + /** Evaluate and reschedule */ + void processClockEvent(); /** Have I been started? and am not stopped */ bool running; -- cgit v1.2.3