[Rd] Rterm.exe, windows event loop running in multiple threads?

Simon Anders anders at ebi.ac.uk
Thu Sep 18 16:04:19 CEST 2008


Hi Michael,

Michael Lawrence wrote:
>>> For processing events, RGtk2 has moved away from using the old tcl_do
hack
>>> and now synchronizes on the Windows event loop. In Rgui.exe this works
>>> fine
>>> (well mostly), but in Rterm.exe, users report the following warning from
>>> GLib: "main loop already active in another thread". The most obvious way
>>> this could occur is if the Windows event loop were iterating in multiple
>>> threads. This does not seem to be the case from my casual inspection of
>>> the
>>> R source.

Following your advice, I have changed my HilbertCurveDisplay package from
the tcl_do hack to your threading technique.

IIRC, you start this second thread whose event handler gets called
periodically by a timer. It checks whether there are any pending Gtk
events, and if so, sends a message to the R main thread in order to cause
one GTK event loop iteration.

I have writen my gtkmm code the same way and got the same error message,
repeated many times. However, after I removed the check for pending events
from the handler of the timer event, the error message vanishes. It seems
that GTK does not like it if gtk_events_pending() is called from two
threads even if both threads refer to the same main loop. (Actually, it
does not mind, as the error is just a warning, and fucntionality ois not
disrupted. I guess that Rgui.exe gets the same warning but fails to
display it.)

Could this be the problem for you as well?

[Thinking a bout this again: Why, actually, do we need a second thread.
Could we not set up a Windows timer that dispatches a message to the main
thread's event handler peridoically to trigger a polling of the Gtk event
loop?]

  Simon



+---
| Dr. Simon Anders, Dipl. Phys.
| European Bioinformatics Institute, Hinxton, Cambridgeshire, UK
| office phone +44-1223-494478, mobile phone +44-7505-841692
| preferred (permanent) e-mail: sanders at fs.tum.de



More information about the R-devel mailing list