Backgroundrb concurrent client access, results services

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

On Jul 14, 2007, at 3:37 PM, Mike Hang wrote:

data
soon digging into the codes to better understand it, but in the mean
time any info would be greatly appreciated.

Thanks,
Mike

Mike-

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 Z.
– Founder & Ruby Hacker
[email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)