[Backgroundrb-devel] Singleton-like Worker

Michael Siebert info at siebert-wd.de
Wed Aug 23 15:30:40 EDT 2006

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060823/9d2fedab/attachment.html 

More information about the Backgroundrb-devel mailing list