Why are signals considered expensive?

Edward Hervey bilboed at bilboed.com
Mon Nov 3 05:58:30 PST 2014


On Mon, 2014-11-03 at 08:49 -0500, Patrick Doyle wrote:
> tl;dr warning -- some of this is for (my) future posterity...
[...]
> OK, so I head on over to the GObject documentation about signals
> (https://developer.gnome.org/gobject/stable/signal.html), and learn
> that "every user event (keystroke or mouse move) is received from the
> X server and generates a GTK+ event under the form of a signal
> emission on a given object instance", which sounds a lot like signals
> should be pretty lightweight.  But then I continue reading about
> signal registration, and the 10 different parameters required
> (including scary things like GClosures and GSignalMarshallers and
> such) and I begin to wonder if that is what is meant by signals being
> considered expensive.

  Yes, that's why it's considering more expensive than a callback (which
is a (more or less) 1-op). The goal of gobject signals is to be
introspectable and using a generic marshalling/callback system (the
signature to connect to a signal is always the same, you can check
argument and argument types at runtime, ...). There are many advantages
to such a system... provided you don't need to use those signal *too*
often. For high frequency calls, better use direct callbacks.

    Edward

> 
> So, I think I'll ask my question anyway (and start a separate thread
> for a different, related question).  Why are signals considered
> expensive?
> 
> --wpd
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel




More information about the gstreamer-devel mailing list