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 <spwilson2@wisc.edu>
Reviewed-on: https://gem5-review.googlesource.com/3744
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
Sean Wilson
2017-06-13 12:26:25 -05:00
parent e34924b50f
commit d0b4774751
2 changed files with 32 additions and 8 deletions

View File

@@ -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)
{
}

View File

@@ -87,7 +87,7 @@ class PacketQueue : public Drainable
void processSendEvent();
/** Event used to call processSendEvent. */
EventWrapper<PacketQueue, &PacketQueue::processSendEvent> 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);