compio-rs / compio

A thread-per-core Rust runtime with IOCP/io_uring/polling.
MIT License
420 stars 37 forks source link

add INVALID_FD constant to use as a default value of uninitialized file descriptor #53

Closed DXist closed 1 year ago

DXist commented 1 year ago

This PR adds INVALID_FD constant - clients could use it as a default value for unitialized file descriptor

Berrysoft commented 1 year ago

What is it for? Could you provide an example?

DXist commented 1 year ago

For example, a driver client doesn't use compio::fs::File abstraction and works with files using only driver operations - like Open, ReadAt, WriteAt, Close operations. The clients File abstraction holds RawFd and reset it to invalid value before file is open or after Close operation is submitted.

In case of Linux/io_uring it's even possible to use only direct descriptors but it could be conditionally compiled into client depending on platform.

Similarly Socket could be used only for bind/listen operations and then transformed back to RawFd.

Berrysoft commented 1 year ago

That's not the goal of this repo.