net: Refactor some Event subclasses to lambdas
Change-Id: I0e23f1529b26c36d749bf5211ee8623744d0b10f Signed-off-by: Sean Wilson <spwilson2@wisc.edu> Reviewed-on: https://gem5-review.googlesource.com/3927 Maintainer: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
@@ -52,7 +52,8 @@ using namespace std;
|
||||
|
||||
EtherBus::EtherBus(const Params *p)
|
||||
: EtherObject(p), ticksPerByte(p->speed), loopback(p->loopback),
|
||||
event(this), sender(0), dump(p->dump)
|
||||
event([this]{ txDone(); }, "ethernet bus completion"),
|
||||
sender(0), dump(p->dump)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -52,19 +52,7 @@ class EtherBus : public EtherObject
|
||||
bool loopback;
|
||||
|
||||
protected:
|
||||
class DoneEvent : public Event
|
||||
{
|
||||
protected:
|
||||
EtherBus *bus;
|
||||
|
||||
public:
|
||||
DoneEvent(EtherBus *b) : bus(b) {}
|
||||
virtual void process() { bus->txDone(); }
|
||||
virtual const char *description() const
|
||||
{ return "ethernet bus completion"; }
|
||||
};
|
||||
|
||||
DoneEvent event;
|
||||
EventFunctionWrapper event;
|
||||
EthPacketPtr packet;
|
||||
EtherInt *sender;
|
||||
EtherDump *dump;
|
||||
|
||||
@@ -84,7 +84,8 @@ class TapEvent : public PollEvent
|
||||
|
||||
EtherTapBase::EtherTapBase(const Params *p)
|
||||
: EtherObject(p), buflen(p->bufsz), dump(p->dump), event(NULL),
|
||||
interface(NULL), txEvent(this)
|
||||
interface(NULL),
|
||||
txEvent([this]{ retransmit(); }, "EtherTapBase retransmit")
|
||||
{
|
||||
buffer = new uint8_t[buflen];
|
||||
interface = new EtherTapInt(name() + ".interface", this);
|
||||
|
||||
@@ -109,21 +109,7 @@ class EtherTapBase : public EtherObject
|
||||
protected:
|
||||
std::queue<EthPacketPtr> packetBuffer;
|
||||
void retransmit();
|
||||
|
||||
class TxEvent : public Event
|
||||
{
|
||||
protected:
|
||||
EtherTapBase *tap;
|
||||
|
||||
public:
|
||||
TxEvent(EtherTapBase *_tap) : tap(_tap) {}
|
||||
void process() { tap->retransmit(); }
|
||||
virtual const char *description() const
|
||||
{ return "EtherTapBase retransmit"; }
|
||||
};
|
||||
|
||||
friend class TxEvent;
|
||||
TxEvent txEvent;
|
||||
EventFunctionWrapper txEvent;
|
||||
};
|
||||
|
||||
class EtherTapInt : public EtherInt
|
||||
|
||||
Reference in New Issue
Block a user