After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 708694 - qdata for main contexts
qdata for main contexts
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: mainloop
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-09-24 17:08 UTC by Allison Karlitskaya (desrt)
Modified: 2018-05-24 15:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GMainContext: add qdata (5.32 KB, patch)
2013-10-03 14:39 UTC, Allison Karlitskaya (desrt)
none Details | Review
Add GAppInfoMonitor (9.72 KB, patch)
2013-10-03 15:37 UTC, Allison Karlitskaya (desrt)
none Details | Review

Description Allison Karlitskaya (desrt) 2013-09-24 17:08:20 UTC
We have these two commonly used patterns in GIO:

 - creating objects that emit signals to the thread-default main context

 - singleton objects that emit signals

Occasionally we combine these two for a semi-singleton there we have one object per-context that emits signals into that context.

Keeping track of these semi-singletons typically involves some sort of hashtable keyed by main context, protected using locking primatives (due to the somewhat obvious threadsafety requirements implied by your support of multiple main contexts).  This is possible using our new weakrefs, but it is not the easiest thing to do.

A nice alternative to having a global hashtable keyed by some object is to have qdata on the object itself.  This would substantially simplify the implementation of any of these sorts of semi-singleton objects.
Comment 1 Allison Karlitskaya (desrt) 2013-10-03 14:39:15 UTC
Created attachment 256393 [details] [review]
GMainContext: add qdata
Comment 2 Colin Walters 2013-10-03 15:31:52 UTC
Can you just give one or two examples?  And an example patch for a consumer inside GLib would be helpful.
Comment 3 Allison Karlitskaya (desrt) 2013-10-03 15:37:37 UTC
Created attachment 256396 [details] [review]
Add GAppInfoMonitor

This is a simple object that emits a "change" signal when the installed
applications may have changed in some way.
Comment 4 Allison Karlitskaya (desrt) 2013-10-03 15:38:14 UTC
Here's an example consumer that will be merged to GLib soon...
Comment 5 Allison Karlitskaya (desrt) 2013-10-15 18:26:53 UTC
I'm starting to go slightly sour on this bug based on the fact that I actually hate qdata being based on Quarks.  We should consider something more like the cairo approach of using a unique pointer.
Comment 6 GNOME Infrastructure Team 2018-05-24 15:42:33 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/760.