async-fs icon indicating copy to clipboard operation
async-fs copied to clipboard

Support OS-specific FileExt traits.

Open songzhi opened this issue 4 years ago • 2 comments

Unix FileExt and Windows FileExt. They are useful when using .read_at(buf, offset) instead of .seek(pos); .read(buf). Because it calls pread(2) instead of lseek(2) + read(2) which is more efficient.

songzhi avatar Oct 29 '20 02:10 songzhi

I'd be willing to work on this (at least for linux), I need it for a project. Would it be possible to get some guidance on how to properly implement this?

I do have a question about this feature though: would this allow one to make multiple read_at,write_at calls in parallel? Or is this, on the kernel level, still a sync operation? Even if the offsets do not collide with each other?

mainrs avatar Oct 05 '22 16:10 mainrs

@mainrs See this docs for pread(2)/pwrite(2):

The pread() and pwrite() system calls are especially useful in multithreaded applications. They allow multiple threads to perform I/O on the same file descriptor without being affected by changes to the file offset by other threads.

songzhi avatar Oct 09 '22 07:10 songzhi