Mike C. wrote:
I admit that I avoid threads altogether unless I have no
choice.
with the average processor today presenting an apparent 8 cores, that’s
no longer a sustainable way to code, I’m afraid.
I think putting your GTK code in a new thread itself is
probably a bad idea. I suspect it should work, but the
threading code in ruby is different than the threads used
by GTK. Sometimes there are problems. If you want to
use threads with GTK you should stick to simple
implementations.
This is about as simple as it gets man – did you read the gui code?
I also seem to remember that GTK calls must be in
the same thread that GTK is started from.
that is interesting. is that “started” the Gtk.init that comes with
require “gtk2” ? Or is it the Gtk.main – they’re actually different
threads here.
Why isn’t that in the ruby-gnome2 api docs? I hate it when a
specification creates several equivalent ways of doing something, only
one of which actually work.
This whole section in my code, will be refactored out to the gui.rb lib
and run entirely in that thread later, but that’s once I build a
readline version of the progress bar and need to offer the user the
option of using that. The idea of using a thread for this came from the
fact that I don’t know how the plugins will work. so its best to let
them update based on the ruby thread scheduler rather than forcing the
plugin programmers to impliment their own schedule. especially when the
gui will be abstracted out as other guis are added in optionally later.
This means
that you have to be a bit careful anyway. A much, much
simpler way to do what you want is to run your network
code in a separate thread and have a Gtk.on_idle
function update your progress bar.
Gtk.on_idle is missing from the ruby gnome 2 api documentation :S lol,
can you up an example please?
But honestly, even that is complicated, since you probably
want to control your app from the gui.
I don’t. I literally only need a progress bar. I dont even need a main
window.
If you are sending long files, write a method that simply sends
a few hundred bytes (or whatever you want).
It would be fast but then I would be responsible for all the plugins and
the system wouldnt be externally extensible.
Wait… I promised not to beat the dead horse…
MikeC
thanks Mike