[Backgroundrb-devel] Status of your worker pool
Ezra Zygmuntowicz
ezmobius at gmail.com
Thu Sep 14 13:39:11 EDT 2006
On Sep 14, 2006, at 10:25 AM, Michael Siebert wrote:
> Hey Ezra,
> how is the status of your worker pool? i need some thing like this
> ASAP and i can't get David Lemstra's QueueWorker to work, so: whats
> the status? do you have some "beta" lying around on your hard
> drive? I dont want to spend my time on that if you're coming up
> with that in a short time, so i'd be happy if I could get my hands
> on some pre-release-worker-pool-thingie :)
>
> kind regards,
> Micha
>
> --
> Michael Siebert <info at siebert-wd.de>
>
> www.siebert-wd.de - Gedanken lesen
> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
Hey Michael-
Yeah I do have a beta here. It is working very well. What I did to
make it easier to refactor was to grab an older version. One that
didn't have any of the Timing stuff or the Threading stuff for
ConditionVariables and all that. Once I got it down to its basic
format, I was able to write a nice ThreadPool class and then use that
in the MiddleMan. So it is way cleaner now. the middleman holds a
thread pool and does all the thread management so the workers don't
have to. It made the code smaller and much more robust.
Here is what I have been playing with.
http://pastie.caboo.se/13279
Its not integrated with the rest of the bdrb infrastructure yet, but
you can play with it. Do this: save that file as bdrb.rb and then run
it like this:
$ irb -r bdrb.rb
You will see it run and output what it is doing while it runs. If
you look at the very bottom of the file you will see where i
instantiate it with a thread pool size of 3 and then try to spawn 15
workers. You can see them go into the pool and wait until other
threads finish so they can get their turn to run. Let me know what
you think. I like how lightweight it is right now so I am debating
what features I want to put back in. In fact this may become
BackgrounDRb2. That way I can make it nicer now that I know how
everyone uses it. But this will maybe change the interface a little
bit so I will leave the current release available for folks that
already buitl a ton on top of it. I also am working on a way to have
'slaves' . This would mean that if you passed an extra flag to the
new_worker method, the drb server will actually fork a new process
for your worker to work in, and it will setup a heartbeat between the
drb server and the slave so that when you kill the drb server, all
slaves will die because they don't get the heartbeat.
Cheers-
-Ezra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060914/eadd9360/attachment.html
More information about the Backgroundrb-devel
mailing list