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 711839 - Add Glib::MainContext::invoke() wrapper
Add Glib::MainContext::invoke() wrapper
Status: RESOLVED OBSOLETE
Product: gnome-perl
Classification: Bindings
Component: Glib
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk2-perl-bugs
gtk2-perl-bugs
Depends on:
Blocks:
 
 
Reported: 2013-11-11 12:56 UTC by Emmanuele Bassi (:ebassi)
Modified: 2021-07-05 12:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add Glib::MainContext::invoke() wrapper (3.90 KB, patch)
2013-11-11 12:56 UTC, Emmanuele Bassi (:ebassi)
none Details | Review

Description Emmanuele Bassi (:ebassi) 2013-11-11 12:56:15 UTC
We should have this in the bindings. See the commit log for more information.
Comment 1 Emmanuele Bassi (:ebassi) 2013-11-11 12:56:22 UTC
Created attachment 259554 [details] [review]
Add Glib::MainContext::invoke() wrapper

Modern GLib is trying to phase out GMainLoop in favour of GMainContext,
especially when it comes to threads usage.

The invoke() method of GMainContext is used in two cases:

  • if the code is using (native) threads with multiple main contexts
    and wishes to invoke a callback function in the correct context,
    which is the case with GIO
  • if the code is using an API that explicitly breaks when used from
    multiple threads, and requires that each callback is invoked a
    specific main context, which is the case of GTK+

The usual way to perform this operation before the introduction of the
g_main_context_invoke() function was to schedule an idle source; this
requires setting up idle sources for specific contexts (thus foregoing
all the convenience API).

Given that the documentation for the libraries based on GLib is starting
to point in the direction of g_main_context_invoke(), the Perl bindins
should provide a wrapper for this function.
Comment 2 Torsten Schoenfeld 2013-12-08 17:31:00 UTC
The patch looks good to me (apart from some minor spaces-vs-tabs issues), but it needs some unit tests.

Also, as far as I can see, this would suffer from the same kinds of problems that the Glib::Idle approach has when used by Perl code running in different threads: If you call $context->invoke() from some thread on a context not attached to that thread, then gperl_main_context_invoke_callback() will access SV* pointers from the calling thread in the context's thread, i.e. it will try to use SV* pointers belonging to one Perl interpreter instance with another Perl interpreter instance.  This is unreliable.  This is not an argument against the patch, however.
Comment 3 GNOME Infrastructure Team 2021-07-05 12:22:09 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME?utf8=%E2%9C%93&filter=perl-

Thank you for your understanding and your help.