danielpclark / rutie

“The Tie Between Ruby and Rust.”
MIT License
938 stars 62 forks source link

Async usage question #141

Closed SpyMachine closed 3 years ago

SpyMachine commented 3 years ago

Hi, I'm looking to use Rutie to build basically a Ruby wrapper around hyper and I'd like to be able to use it in an async manner.

I saw it was mentioned in #118 that you recommend one master thread for communication back and forth between Ruby and Rutie.

I'm thinking the best way to implement this is where we have a blocking function that we can call from Ruby that adds requests to a queue, and then another blocking function that we call from Ruby that allows the user to pull responses from a queue and we have a separate runtime in the background that let's hyper do its thing.

Does this seem to make sense to you or do you see a better approach?

Thanks!

danielpclark commented 3 years ago

Sure. I don't see why not. One thing to keep in mind is Ruby's way of throwing exceptions. There is a global state of when an exception has been thrown and I know that per fork (not using threading) it'll stop the whole fork, but I don't know how that's managed with threading. So that may be something to keep in mind.