rio icon indicating copy to clipboard operation
rio copied to clipboard

suggestions for designing event loop around rio interface

Open jonathanstrong opened this issue 3 years ago • 0 comments

hello,

I was wondering if you could offer advice about how to store pending Completion instances while you are waiting for them to be completed, potentially doing other work in the meantime and submitting additional tasks to the queue.

the two issues I ran into while attempting a demo event loop design around Rio were:

  1. no way to storeCompletion instances returned by my ring, as taking an immutable reference into a collection would prevent the ability to add additional items to it, and
  2. no way to check if a Completion is done without blocking (not sure if this is avoidable, I am not a io-uring expert (yet))

I posted some code here, which is where I stopped, unable to figure out how I would go further: https://gist.github.com/jonathanstrong/0d8aaef2fbbb62d2ddcd291f62a03114

my goal is for a thread pool worker to be receiving io jobs over a channel, submitting work to the ring, potentially for several unrelated jobs at once, then processing the results from the ring as they become available, and sending back info/data about the outcome of the work to the thread that sent the job upon that result becoming available.

another, more big picture way of saying this is, how do I store the context (buffer/file) of a Rio submission, other than a named stack variable as in the examples?

thanks for any help you can provide!

jonathanstrong avatar May 06 '21 19:05 jonathanstrong