Out of band stuff?

Damian Janowski jano at dimaion.com
Tue Apr 10 20:24:56 UTC 2012

On Mon, Apr 9, 2012 at 12:05 AM, Eric Wong <normalperson at yhbt.net> wrote:
> If you look at the `call' method in raindrops/watcher.rb, the important
> line is this:
>        # @start is a Mutex and @thr is nil in the initialize method.
>        @start.synchronize { @thr ||= aggregator_thread(env["rack.logger"]) }
> I avoid starting the background thread at initialization because it'll
> die on fork (meaning I'd have to recheck it all the time, anyways).
> The overhead of Mutex#synchronize and @thr||= assignment is negligible
> in most apps.

One more question. Can you confirm that this technique doesn't work as
expected using Rainbows/ThreadPool? I've found that Rack::Builder
creates a new instance of each middleware on every request, so you'd
end up spawning infinite aggregator threads.

More information about the rainbows-talk mailing list