From d0b477475135f7d216fcdfa5a2c22266234801bc Mon Sep 17 00:00:00 2001 From: Sean Wilson Date: Tue, 13 Jun 2017 12:26:25 -0500 Subject: [PATCH] mem: Replace EventWrapper in PacketQueue with EventFunctionWrapper In order to replicate the same `name()` output with `PacketQueue`, subclasses using EventFunctionWrapper must initialize PacketQueue with their own name so the sendEvent holds the name of the subclass. Change-Id: Ib091e118bab8858192e1d1370d61def42958ec29 Signed-off-by: Sean Wilson Reviewed-on: https://gem5-review.googlesource.com/3744 Reviewed-by: Nikos Nikoleris Reviewed-by: Jason Lowe-Power Maintainer: Nikos Nikoleris --- src/mem/packet_queue.cc | 13 +++++++++---- src/mem/packet_queue.hh | 27 +++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/mem/packet_queue.cc b/src/mem/packet_queue.cc index f7df3314f..7649fe5a6 100644 --- a/src/mem/packet_queue.cc +++ b/src/mem/packet_queue.cc @@ -50,8 +50,10 @@ using namespace std; PacketQueue::PacketQueue(EventManager& _em, const std::string& _label, + const std::string& _sendEventName, bool disable_sanity_check) - : em(_em), sendEvent(this), _disableSanityCheck(disable_sanity_check), + : em(_em), sendEvent([this]{ processSendEvent(); }, _sendEventName), + _disableSanityCheck(disable_sanity_check), label(_label), waitingOnRetry(false) { } @@ -237,7 +239,8 @@ PacketQueue::drain() ReqPacketQueue::ReqPacketQueue(EventManager& _em, MasterPort& _masterPort, const std::string _label) - : PacketQueue(_em, _label), masterPort(_masterPort) + : PacketQueue(_em, _label, name(_masterPort, _label)), + masterPort(_masterPort) { } @@ -250,7 +253,8 @@ ReqPacketQueue::sendTiming(PacketPtr pkt) SnoopRespPacketQueue::SnoopRespPacketQueue(EventManager& _em, MasterPort& _masterPort, const std::string _label) - : PacketQueue(_em, _label), masterPort(_masterPort) + : PacketQueue(_em, _label, name(_masterPort, _label)), + masterPort(_masterPort) { } @@ -262,7 +266,8 @@ SnoopRespPacketQueue::sendTiming(PacketPtr pkt) RespPacketQueue::RespPacketQueue(EventManager& _em, SlavePort& _slavePort, const std::string _label) - : PacketQueue(_em, _label), slavePort(_slavePort) + : PacketQueue(_em, _label, name(_slavePort, _label)), + slavePort(_slavePort) { } diff --git a/src/mem/packet_queue.hh b/src/mem/packet_queue.hh index b1001e75d..f7379c900 100644 --- a/src/mem/packet_queue.hh +++ b/src/mem/packet_queue.hh @@ -87,7 +87,7 @@ class PacketQueue : public Drainable void processSendEvent(); /** Event used to call processSendEvent. */ - EventWrapper sendEvent; + EventFunctionWrapper sendEvent; /* * Optionally disable the sanity check @@ -134,6 +134,7 @@ class PacketQueue : public Drainable * on the size of the transmitList. The check is enabled by default. */ PacketQueue(EventManager& _em, const std::string& _label, + const std::string& _sendEventName, bool disable_sanity_check = false); /** @@ -215,6 +216,12 @@ class ReqPacketQueue : public PacketQueue MasterPort& masterPort; + // Static definition so it can be called when constructing the parent + // without us being completely initialized. + static const std::string name(const MasterPort& masterPort, + const std::string& label) + { return masterPort.name() + "-" + label; } + public: /** @@ -232,7 +239,7 @@ class ReqPacketQueue : public PacketQueue virtual ~ReqPacketQueue() { } const std::string name() const - { return masterPort.name() + "-" + label; } + { return name(masterPort, label); } bool sendTiming(PacketPtr pkt); @@ -245,6 +252,12 @@ class SnoopRespPacketQueue : public PacketQueue MasterPort& masterPort; + // Static definition so it can be called when constructing the parent + // without us being completely initialized. + static const std::string name(const MasterPort& masterPort, + const std::string& label) + { return masterPort.name() + "-" + label; } + public: /** @@ -262,7 +275,7 @@ class SnoopRespPacketQueue : public PacketQueue virtual ~SnoopRespPacketQueue() { } const std::string name() const - { return masterPort.name() + "-" + label; } + { return name(masterPort, label); } bool sendTiming(PacketPtr pkt); @@ -275,6 +288,12 @@ class RespPacketQueue : public PacketQueue SlavePort& slavePort; + // Static definition so it can be called when constructing the parent + // without us being completely initialized. + static const std::string name(const SlavePort& slavePort, + const std::string& label) + { return slavePort.name() + "-" + label; } + public: /** @@ -292,7 +311,7 @@ class RespPacketQueue : public PacketQueue virtual ~RespPacketQueue() { } const std::string name() const - { return slavePort.name() + "-" + label; } + { return name(slavePort, label); } bool sendTiming(PacketPtr pkt); -- 2.30.2