Number of subscribers of a GLib signal

Hello:

Is it possible to know if there are (or not) subscribers of an specific signal?

My idea is to subscribe to several signals, and whenever there is some changes that I check every time any of them are triggered, I trigger my own signal. But I don’t want to do that work if there is no one connected to that own signal, so what I want is to detect when someone subscribe to that signal, and only there subscribe the inner code to all those signals and do that work.

Is it possible to do that with GLib, or do I have to do my own set of functions to manage that by myself?

Thanks.

https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-has-handler-pending ?

This is inherently racy, and won’t ever work correctly; see these issues:

The only thing you can do is to check if there are handlers connected to a signal before emitting the signal, using g_signal_has_handler_pending(), but it must not be used to decide whether or not to connect to a signal because the signal in question may or may not have a class handler.

My idea was more like registering a callback which is called whenever a “connect” or “disconnect” is done for an specific signal in an object. That wouldn’t be racy. But by your answer, I presume that it doesn’t exist :’(

Anyway, the answer of Peter offers another solution.

ebassi: wow… yes, it seems it is much more complex than I though. Thanks for the links!