Hi,
Are there any plans to pepper the codebase with rb_blocking_region
calls? If so, is there a preferred way to approach it?
I’ve attached a sample patch for Gdk::Pixbuf.new that allows loading
from disk to play nicely with threads, but it’s rather ugly. On the
plus side, it makes a script like the following take about ~1s instead
of >4.5s when run on my 6 core AMD with an 8Mb JPEG.
—8<—
require ‘glib2’
$:.unshift ‘./gdk_pixbuf2/ext/gdk_pixbuf2/’
require ‘gdk_pixbuf2.so’
require ‘thread’
threads = []
pixbufs = []
m = Mutex.new
Thread.new { loop { GC.start; Thread.sleep(0.01) } }
12.times do
threads << Thread.new {
pb = Gdk::Pixbuf.new(ARGV[0])
m.synchronize { pixbufs << pb }
}
end
threads.each(&:join)
p pixbufs
—8<—
So - any thoughts on whether the best way to implement Ruby 1.9 thread
support for those sections of ruby-gnome2 which are usefully
threadable?
TTFN,
G