rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.61k stars 12.74k forks source link

Tracking Issue for File lock API #130994

Open cberner opened 1 month ago

cberner commented 1 month ago

Feature gate: #![feature(file_lock)]

This is a tracking issue for https://github.com/rust-lang/libs-team/issues/412

This feature exposes advisory file locks on File. They allow a file handle to acquire an exclusive or shared file lock, which blocks other file handles to the same file from acquiring a conflicting lock. Some semantics are platform dependent, and these are documented in the API documentation.

Public API

impl File {
    fn lock(&self) -> io::Result<()>;
    fn lock_shared(&self) -> io::Result<()>;
    fn try_lock(&self) -> io::Result<bool>;
    fn try_lock_shared(&self) -> io::Result<bool>;
    fn unlock(&self) -> io::Result<()>;
}

Steps / History

Unresolved Questions

workingjubilee commented 4 days ago

apparently not supported on all tier 2 OS: https://github.com/rust-lang/rust/issues/132921