Linux raw file handle to async stream

Hey All,

I have a Linux-specific library that can give me a raw OS file handle (as a c_int) that can be used in a call to the Linix poll() family of functions to indicate when you can read or write a buffer without blocking.

Is there an easy way to wrap a file handle into an async-stream without relying on a specific runtime like Tokio or async-std? Meaning: how might I wake up the task if it's not ready on an initial poll?

For background this is using the Linux Industrial I/O subsystem for analog I/O. The file handle is not used for doing the subsequent read() or write(), so it doesn't map to a File type operation. The file handle is just a "ready" signal. When ready you need to call refill() on an opaque type to read, or push() on the type to write.

As always, thanks for the help!

No, this requires integration with the event-loop, so it must be runtime-specific. With Tokio, you can use PollEvented.

Aww. I was afraid of that. Thanks, @alice.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.