From ea57eee60cca92277f9f8d1f2abf501ca158be2e Mon Sep 17 00:00:00 2001 From: Sean Wilson Date: Wed, 28 Jun 2017 11:18:55 -0500 Subject: [PATCH] net: Refactor some Event subclasses to lambdas Change-Id: I0e23f1529b26c36d749bf5211ee8623744d0b10f Signed-off-by: Sean Wilson Reviewed-on: https://gem5-review.googlesource.com/3927 Maintainer: Jason Lowe-Power Reviewed-by: Jason Lowe-Power Reviewed-by: Andreas Sandberg --- src/dev/net/etherbus.cc | 3 ++- src/dev/net/etherbus.hh | 14 +------------- src/dev/net/ethertap.cc | 3 ++- src/dev/net/ethertap.hh | 16 +--------------- 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/dev/net/etherbus.cc b/src/dev/net/etherbus.cc index 7ccb8a4ac..243e27b18 100644 --- a/src/dev/net/etherbus.cc +++ b/src/dev/net/etherbus.cc @@ -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) { } diff --git a/src/dev/net/etherbus.hh b/src/dev/net/etherbus.hh index 7395c28d8..1b264533c 100644 --- a/src/dev/net/etherbus.hh +++ b/src/dev/net/etherbus.hh @@ -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; diff --git a/src/dev/net/ethertap.cc b/src/dev/net/ethertap.cc index 0c027b621..59314e540 100644 --- a/src/dev/net/ethertap.cc +++ b/src/dev/net/ethertap.cc @@ -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); diff --git a/src/dev/net/ethertap.hh b/src/dev/net/ethertap.hh index 96cc4710c..9b4e175e1 100644 --- a/src/dev/net/ethertap.hh +++ b/src/dev/net/ethertap.hh @@ -109,21 +109,7 @@ class EtherTapBase : public EtherObject protected: std::queue 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 -- 2.30.2