[Backgroundrb-devel] adding results from threads to a collection and returning it

hemant gethemant at gmail.com
Fri Jun 13 06:33:04 EDT 2008

On Fri, Jun 13, 2008 at 2:15 PM, Stevie Clifton <stevie at slowbicycle.com> wrote:
> Hey Hemant,
> A couple of questions about fetch_parallely:
> 1)  Does it operate in the same way as thread_pool.defer, where the
> number of concurrent threads are limited by :pool_size?
> 2)  Why did you choose to introduce another method instead of
> providing a thread-safe register_status? (more out of curiosity than
> anything else -- in my code I've overridden register_status to use a
> Mutex, and am wondering what the benefit of fetch_parallely would be
> to this)

register_status is going to invoke send_data at one point or another.
yeah sure, prolly i can make outbound_data instance variable protected
by a mutex, but thats going to slow down the whole operation by a
large margin. Thats not simply point of a event driven network
programming library.  It will mean that, I will have to check for
mutex, each time i write. What a waste of time it will be!

Now, on the other hand, if we can make sure that, we retrieve results
from thread pool in a thread safe manner and then invoke send_data,
everything is nice and dandy. fetch_parallely does exactly that. Name
is a bit dubious, i didn't want to break existing functionality and at
the same time, wanted to add this. Let me know, if you have better

More information about the Backgroundrb-devel mailing list