[Backgroundrb-devel] Singleton-like Worker

P. Mark Anderson mark at martianrover.com
Wed Aug 23 16:27:34 EDT 2006


+1 useful on the thread pool.  I can't wait.  Really.  The queue I  
wrote has two priority levels so that quick or important tasks  
execute before those of normal priority.  It'd be great if  
Backgroundrb managed it all.

pmark




On Aug 23, 2006, at 12:44 PM, Ezra Zygmuntowicz wrote:

>
> 	Sure I will take a look at it. But I might wait until after I  
> implement a thread pool to add it in. I am planning to make a  
> configurable thread pool for workers. So you could say that 30  
> workers can be running at a time max. Then when you already have 30  
> workers running, and you ask it to run another that one will go  
> into the wait pool until one of the first 30 finishes and makes  
> room. This will make it safer to run a lot of workers and you will  
> be able to taylor the size of the pool to fit your situation. But  
> yeah do send me the code so I can see what you did.
>
> Cheers-
> -Ezra
>
>
> On Aug 23, 2006, at 12:30 PM, Michael Siebert wrote:
>
>> built upon the singleton code, i made a little option :queue_run  
>> and modified Backgroundrb::rails to wait in that case. little  
>> hackery though, but it works.
>> wanna have it? (as always not tested, no unit tests no nothing)
>>
>> 2006/8/23, Ezra Zygmuntowicz <ezmobius at gmail.com>:
>>
>> On Aug 23, 2006, at 11:33 AM, Michael Siebert wrote:
>>
>>> Hello there,
>>> I need a Worker Class to be Singleton-like, that means there must  
>>> be at maximum one Instance at a time. When a new Request is made  
>>> to create another worker of this type, it should return and wait  
>>> for the other instance to be destroyed.
>>>
>>> what i need to do: i have a worker who needs to do sth with java  
>>> and openoffice, and it seems when i have more tha one worker  
>>> simultaneously, everything goes terribly wrong...
>>>
>>> is there already sth in bgdrb or how would i do that?
>>>
>>> -- 
>>> Michael Siebert <info at siebert-wd.de>
>>>
>>
>> Hey Michael-
>>
>> 	Yeah there is already singleton type workers in the plugin.  It  
>> doesn't work exactly as you want it to though. When you create a  
>> singleton worker it will start doing its thing and any call to  
>> new_worker for the same singleton will just return the key for the  
>> already existing singleton worker. So you are always garaunteed to  
>> get the same singleton. There is not currently any support for  
>> returning and then starting up after the singleton dies. But check  
>> it out anyway as it might do what you want.
>>
>> There is also now an option to have a singleton worker so there is  
>> always
>> only one of a certain worker. Even if you call new_worker twice  
>> with this
>> option enabled you will get back the same instance of the class.  
>> Do not
>> create a worker class and use it as a singleton and a non  
>> singleton worker
>> at the same time. This is not supported.
>>
>> MiddleMan.new_worker(:class => :foo_worker,
>>                      :args => "Bar",
>>                      :job_key => :singleton_worker,
>>                      :singleton => true)
>>
>>
>> -Ezra
>>
>>
>>
>>
>> -- 
>> Michael Siebert <info at siebert-wd.de>
>>
>> www.siebert-wd.de - Gedanken lesen
>> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
>> _______________________________________________
>> Backgroundrb-devel mailing list
>> Backgroundrb-devel at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/88b9cb5a/attachment.html 


More information about the Backgroundrb-devel mailing list