ringbahn / ringbahn

safe bindings to io-uring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Revising the iou part of the interface

withoutboats opened this issue · comments

Once I merge #29, ringbahn will provide working File, TcpListener, and TcpStream types, which are not 100% API complete, but which basically work. I want to turn my attention to two different problems.

One is solving #2: adding an interface to Drive for drivers to provide the buffers used for IO, which could be used to preregister buffers etc.

The other is changing the interface to iou. Basically, I think I will need to incorporate iou into this library, possibly exposing a different interface. This makes iou a dead-end from my perspective, unfortunately.

This revision would help solve many problems:

  1. Currently, implementing a driver requires unsafe code, because the complete function is unsafe. The only thing users need to meet this requirement is never assign user_data themselves. We could instead make setting user_data an unsafe operation, making the entire interface for driver 100% safe.
  2. We could make this interface supporting mocking of SQEs and CQEs, allowing users to implement totally mock drivers after #18.
  3. In order to solve both #3 and #22 we need a way for poll_prepare to require more than 1 sequential SQE. (Possibly, these SQEs would also be automatically linked by ringbahn). iou's current interface is not conducive to that.
  4. As it stands, iou is designed around wrapping the entire submission side interface in a mutex. However, this is not strictly necessary: separate SQEs can be accessed concurrently (essentially like iterating mutably over the SQ), and then when all SQE references are dropped, submission can occur. This makes it more like a RwLock than a Mutex. Ideally, the new interface would make this easy to implement with safe code.