sim: Add a listener checker to probes
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Tue, 1 Dec 2020 14:24:56 +0000 (15:24 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Wed, 16 Dec 2020 12:13:05 +0000 (12:13 +0000)
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 <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38175
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
src/sim/probe/probe.hh

index 57132fc8b4c3b6fdb5f99301380c2b4116ae3295..5becc26f27715dc9ce67c3fcf594a4e8b2593784 100644 (file)
@@ -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.