Ciro Santilli has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/37977 )
Change subject: sim: make ProbeListener satisfy the rule of five with
deleted
......................................................................
sim: make ProbeListener satisfy the rule of five with deleted
Since this class has a custom destructor ~ProbeListener(), it should
also generally have the 4 other methods defined, otherwise calling
those methods lead to subtle failures.
In this specific case, the ProbeManager *const manager; field stores a
pointer back to the ProbeListener object at:
ProbeListener::ProbeListener {
manager->addListener(name, *this);
which gets unregistered by the destructor:
ProbeListener::~ProbeListener()
manager->removeListener(name, *this);
and because the default copy does not re-register anything, it leads to
unregistration.
Therefore, a copy constructor would need the manager to support multiple
identical listeners, or at least refcount them, which would be overkill.
The two move operations would be more feasible, as we could make them
unregister the old ProbeListener address and then re-register the new one,
but that is not very efficient, so we just delete them as well.
A consequence of not implementing the move methods is that it is
impossible to store ProbeListener inside an std::vector. since objects
inside std::vector may need to be moved in memory when the vector resizes,
and therefore need to be movable. The alternative is to use an std::vector
of std::unique_ptr instead.
Change-Id: I8dc0157665391f86e2ca81d144bc6a42e9312d6c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37977
Reviewed-by: Andreas Sandberg <[email protected]>
Maintainer: Andreas Sandberg <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/sim/probe/probe.hh
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/sim/probe/probe.hh b/src/sim/probe/probe.hh
index 97edf0b..57132fc 100644
--- a/src/sim/probe/probe.hh
+++ b/src/sim/probe/probe.hh
@@ -119,6 +119,10 @@
public:
ProbeListener(ProbeManager *manager, const std::string &name);
virtual ~ProbeListener();
+ ProbeListener(const ProbeListener& other) = delete;
+ ProbeListener& operator=(const ProbeListener& other) = delete;
+ ProbeListener(ProbeListener&& other) noexcept = delete;
+ ProbeListener& operator=(ProbeListener&& other) noexcept = delete;
protected:
ProbeManager *const manager;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/37977
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: I8dc0157665391f86e2ca81d144bc6a42e9312d6c
Gerrit-Change-Number: 37977
Gerrit-PatchSet: 2
Gerrit-Owner: Ciro Santilli <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Ciro Santilli <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s