pub struct FileDevice { /* private fields */ }Expand description
A file opened as a block device.
§Reads do not take the lock; writes do
A read was seek then read under a mutex, which made the file’s
cursor shared state: two threads reading different offsets had to
take turns, not because the device could not serve them at once but
because one would have moved the other’s cursor.
On Unix the cursor is not involved at all — pread takes the offset
as an argument — so reads run without the lock and genuinely overlap.
On Windows the equivalent (seek_read) does move the file
pointer, so the lock stays there. Same behaviour, one platform
paying for it.
Writes keep the lock on both, because write_at is still seek plus
write_all and a partial write must not have another writer’s seek
land in the middle of it.
Implementations§
Trait Implementations§
Source§impl BlockDevice for FileDevice
impl BlockDevice for FileDevice
Auto Trait Implementations§
impl !Freeze for FileDevice
impl RefUnwindSafe for FileDevice
impl Send for FileDevice
impl Sync for FileDevice
impl Unpin for FileDevice
impl UnsafeUnpin for FileDevice
impl UnwindSafe for FileDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more