Arthur wrote:
> Unfortunately I don�t want to read from or write to files.
> I want to do a non-blocking `Dir['./some/dir/**/*']` or similar.
>
> For now I would go with a `find -printf ...` command. And read the
> lines into a queue, which processes the files.
>
> Isn�t there a better way?
Perhaps a job for `defer` ?
http://eventmachine.rubyforge.org/EventMachine.html#M000486
This assumes, though, that Dir.glob doesn't itself block all
Ruby threads from running. In ruby 1.8 it might block every
ruby thread anyway. In ruby 1.9 it might run asynchronously
in its own thread (assuming Dir.glob's C implementation is
wrapped with the appropriate thread_nonblocking_region calls.)
So, assuming Dir.glob does not block all threads while it
executes, I'd expect EventMachine.defer to work.
Regards,
Bill