--
You received this message because you are subscribed to the Google Groups "Concurrent Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concurrent-ru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hey there,
Firstly, I would agree with those that say that async IO isn’t necessary with concurrent-ruby in a lot of cases. In my experience, it becomes useful when you need to have a large number of file handles open at once and having a thread for every one is too expensive.
I have an unfinished but usable library that can be do async socket IO with concurrent-ruby. It is here: https://github.com/asppsa/concurrent_io. There’s no up-to-date gem at the moment, although the code is being used in a production environment to run a websocket server. I created the gem because I ran into resource problems like I mentioned above. The README is hopelessly outdated, so in brief …
The project wraps various async IO ruby frameworks (the main one being
eventmachine, but there is also plain ruby support using IO#select
,
and some support for nio4r).
In all cases, it runs a single “selector” thread that watches a set of IO objects for availability to read/write or for close/error events, and then notifies an object.
The main use case at the moment is to give the CR Actor framework a means of passing messages across sockets, but its not limited to using actors. If your use case doesn’t involve sockets though, I’m not sure how well it will work.
You can check out the examples
folder to see a basic example of how
to do ping-pong over a socket.
If you’re interested in using this at all I can endeavour to clean it up
a bit and make a release. Another possibility is you could look into
the Rails ActionCable codebase, as I understand that it uses CR and does
async IO somehow. Part of the reason that I’ve not bothered to release
concurrent_io
is that I somewhat expected it to be superceded by the
work of the rails team.
Cheers,
Alastair
On 23 July 2016 at 06:55, Arindam Mukherjee wrote:
I am a concurrent-ruby noob but find immediate value in this library for use in my work. I had been investigating reactor-models for doing async-IO and was looking EventMachine. But my requirements go well-beyond just async-IO. In a peanut-shell, I need to run I/O bound tasks that may sometimes do CPU-bound stuff. They are workflow like, so something like Concurrent::Future.dataflow seems very useful.
With that said, are there any recommendations on how to optimally do I/O using concurrent-ruby.
- Should I just create futures that do blocking I/O and rely on the internal threadpool to schedule these operations?
- Are there any async I/O libraries for different protocols that are suggested for use with concurrent-ruby?
- Is there some way to use Fibers in conjunction with concurrent-ruby or is it mostly not needed?
Thanks,
Arindam–