From: Daniel R. Carvalho Date: Tue, 1 Dec 2020 14:24:56 +0000 (+0100) Subject: sim: Add a listener checker to probes X-Git-Tag: develop-gem5-snapshot~356 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9388ec18a40c2fc4467f5599daad4970e565016b;p=gem5.git 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 --- 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.