[Backgroundrb-devel] What happens if?
apsoto at gmail.com
Sun Feb 10 15:59:33 EST 2008
Am I understanding correctly that a task that is doing work would get
interrupted and it's current job is effectively canceled?
On Feb 10, 2008, at 6:29 AM, hemant kumar wrote:
> On Sun, 2008-02-10 at 14:54 +0200, Cosmin Radoi wrote:
>> I'm new to the list so I'd like to first greet everybody and thank
>> Ezra for the nice solution to an old problem.
>> I also have a warm-up newbie question. What happens if I send a
>> request to a worker that in that moment is working on some other
>> Does it wait for the worker to finish his current method and than
>> evaluate my request, does it interrupt the worker to handle the
>> request or does it simply spawn another thread for it?
> If you invoke ask_work on a worker thats already processing a
> task( in a
> totally blocking manner ), then your request will be queued in master
> process send_data buffer, until your worker is free and ready to
> the data ready at the socket and start executing next task.
> Since bdrb makes use of non blocking IO and select call to check for
> availability of data at the socket, assuming your worker is doing some
> processing because of which reactor loop is not able to run through
> iteration ( in each iteration it checks if there is data to be read
> the socket ), your request will be queued up in socket buffer. For
> couple of requests this fine, but if you are making too many requests
> and your requests are getting queued in socket buffer, its not a good.
> However, if you are processing too many tasks and want to spawn a
> for them, you can rather use inbuilt, "thread_pool" to defer execution
> of tasks to a pool of threads. It works nicely and will probably work
> better than roll your own thread solution.
> For more information refer the README file or documentation here at:
> Finally in no case, a running tasks gets interrupted.
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
More information about the Backgroundrb-devel