On Feb 2, 2008 11:56 PM, Benjamin H. Bryant <[EMAIL PROTECTED]> wrote:
> Within a threaded worker, I would like to have multiple methods.  Will
> the following code work?
>
> def method_1(args)
>
>    thread_pool.defer(args) do |args|
>      #work
>    end
>
> end
>
> def method_2(args)
>
>    thread_pool.defer(args) do |args|
>     #work
>    end
>
> end

Yes that will work fine. The thread_pool.defer call just packages the
block and arguments into a class which is put into a queue. The
thread_pool pulls from that queue and executes the packaged code in
the order it was received.

Since I was making use of thread_pool.defer myself I read the source
to see what it was doing, which is nothing too crazy.

Regards,
Ryan
_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel

Reply via email to