From 9388ec18a40c2fc4467f5599daad4970e565016b Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Tue, 1 Dec 2020 15:24:56 +0100 Subject: [PATCH] sim: Add a listener checker to probes Add a function to check if a probe has listeners. This can be used to avoid performing costly tasks when no one is listening. Change-Id: I8996a0ea298cb7cf97ac8aa9e627331a22bea26e Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38175 Maintainer: Jason Lowe-Power Tested-by: kokoro Reviewed-by: Jason Lowe-Power Reviewed-by: Nikos Nikoleris --- src/sim/probe/probe.hh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sim/probe/probe.hh b/src/sim/probe/probe.hh index 57132fc8b..5becc26f2 100644 --- a/src/sim/probe/probe.hh +++ b/src/sim/probe/probe.hh @@ -261,6 +261,15 @@ class ProbePointArg : public ProbePoint { } + /** + * Informs whether any listeners are attached to this probe. This can + * be used to avoid performing costly tasks needed by the probe when + * nobody is listening. + * + * @return Whether this probe has any listener. + */ + bool hasListeners() const { return listeners.size() > 0; } + /** * @brief adds a ProbeListener to this ProbePoints notify list. * @param l the ProbeListener to add to the notify list. -- 2.30.2