Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/32643 )
Change subject: mem: Use the new type of CallbackQueue in the MemBackdoor.
......................................................................
mem: Use the new type of CallbackQueue in the MemBackdoor.
Issue-on: https://gem5.atlassian.net/browse/GEM5-698
Change-Id: Ide40528f8c613b46204550d6e6840a7b274a366a
---
M src/mem/backdoor.hh
1 file changed, 4 insertions(+), 31 deletions(-)
diff --git a/src/mem/backdoor.hh b/src/mem/backdoor.hh
index d5e5f0d..42540eb 100644
--- a/src/mem/backdoor.hh
+++ b/src/mem/backdoor.hh
@@ -42,28 +42,6 @@
// a const reference to this back door as their only parameter.
typedef std::function<void(const MemBackdoor &backdoor)> CbFunction;
- private:
- // This wrapper class holds the callables described above so that they
- // can be stored in a generic CallbackQueue.
- class Callback : public ::Callback
- {
- public:
- Callback(MemBackdoor &bd, CbFunction cb) :
- _backdoor(bd), cbFunction(cb)
- {}
-
- void process() override { cbFunction(_backdoor); }
- // It looks like this is only called when the CallbackQueue is
- // destroyed and this Callback is currently in the queue.
- void autoDestruct() override { delete this; }
-
- MemBackdoor &backdoor() { return _backdoor; }
-
- private:
- MemBackdoor &_backdoor;
- CbFunction cbFunction;
- };
-
public:
enum Flags{
// How data is allowed to be accessed through this backdoor.
@@ -108,7 +86,6 @@
void flags(Flags f) { _flags = f; }
MemBackdoor(AddrRange r, uint8_t *p, Flags flags) :
- invalidationCallbacks(new CallbackQueue),
_range(r), _ptr(p), _flags(flags)
{}
@@ -121,9 +98,7 @@
void
addInvalidationCallback(CbFunction func)
{
- auto *cb = new MemBackdoor::Callback(*this, func);
- assert(cb);
- invalidationCallbacks->add(cb);
+ invalidationCallbacks.push_back(func);
}
// Notify and clear invalidation callbacks when the data in the
backdoor
@@ -133,14 +108,12 @@
void
invalidate()
{
- invalidationCallbacks->process();
- // Delete and recreate the callback queue to ensure the callback
- // objects are deleted.
- invalidationCallbacks.reset(new CallbackQueue());
+ invalidationCallbacks.process(*this);
+ invalidationCallbacks.clear();
}
private:
- std::unique_ptr<CallbackQueue> invalidationCallbacks;
+ CallbackQueue2<const MemBackdoor &> invalidationCallbacks;
AddrRange _range;
uint8_t *_ptr;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/32643
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ide40528f8c613b46204550d6e6840a7b274a366a
Gerrit-Change-Number: 32643
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s