From: Laurent S. <lau...@gm...> - 2008-03-14 00:25:44
|
Hi Matias, On Thu, Mar 13, 2008 at 4:31 PM, Matias Pablo Brutti <mat...@gm...> wrote: > Hi , > > I've read that rubycocoa has some issues with threads , NSThreads, which > will be the best approach to take to actually use threads?, which type of > threads should I use and finally is there an example or doc on rubycocoa > threads that you recommend ?, > > I'm implementing an application that makes lots of requests which takes some > time. My idea is to thread that process and while I receiving he info update > the TableView, all this while not frezzing my main application but without > threads I do not see how to do that. any ideas ? > The current version of Ruby (1.8) not being thread-safe, it is currently impossible to use NSThreads. Well you can, but RubyCocoa will route calls into the main thread for you (to avoid crashing), and it might cause a deadlock sometimes. The preferable way is to use Ruby threads instead. In Leopard, both the interpreter and RubyCocoa were modified to support calling Objective-C from Ruby threads. But this support is not ideal (you can see that as a hack), and sometimes it doesn't work. You can also use NSTimers or any other mechanism driven by the Cocoa runloop. HTH, Laurent |