First thank to backgroundrb, it sure makes distribute computing a lot easier. A couple of questions: 1. I don''t fully understand the reason for Results services, can I just create instance vars, methods within the Worker class help to exposed shared result data? I did notice about results being alive after the Worker is deleted. Is this the only reason? 2. Continue with the first question, since I have no need to access data after the Worker is deleted, I rather not introduce additional book keeping. I want to introduce instance vars and methods to access data within the Worker. Will I have to worry data corruption/sync problem if I have multiple MiddleMan clients accessing the same Worker that may be calling instance vars and/or methods at the same time. Or if I just use the Results service, my worries goes away. I guess I will spend sometime soon digging into the codes to better understand it, but in the mean time any info would be greatly appreciated. Thanks, Mike -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ezra Zygmuntowicz
2007-Jul-14 22:59 UTC
Re: backgroundrb concurrent client access, results services
On Jul 14, 2007, at 3:37 PM, Mike Hang wrote:> > First thank to backgroundrb, it sure makes distribute computing a lot > easier. A couple of questions: > 1. I don''t fully understand the reason for Results services, can I > just > create instance vars, methods within the Worker class help to exposed > shared result data? I did notice about results being alive after the > Worker is deleted. Is this the only reason? > > 2. Continue with the first question, since I have no need to access > data > after the Worker is deleted, I rather not introduce additional book > keeping. I want to introduce instance vars and methods to access data > within the Worker. Will I have to worry data corruption/sync > problem if > I have multiple MiddleMan clients accessing the same Worker that > may be > calling instance vars and/or methods at the same time. Or if I just > use > the Results service, my worries goes away. I guess I will spend > sometime > soon digging into the codes to better understand it, but in the mean > time any info would be greatly appreciated. > > Thanks, > MikeMike- Stay away from the results worker and just use methods and instance variables. The results worker is only useful if you want to keep some results around after you kill your worker. ALso the results worker is a tad broken right now as well. If you need to have multiple access to variables in a worker then you may need to synchronize access to instance variables and methods with a mutex. add a ''lock'' helper method like this to your worker: def lock @_lock ||= Mutex.new @_lock.synchronize { yield } end And then use it every time you have an area of code that could get accessed by multiple clients at once: def important_method lock do # some important thing in here that only #should be accessed by one thread at a time end end Cheers- -- Ezra Zygmuntowicz -- Founder & Ruby Hacker -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---