Skip to content

Commit 271a3d1

Browse files
committed
Reword file lock documentation to clarify advisory vs mandatory
Remove the word "advisory", and make it more explicit that the lock may be advisory or mandatory depending on platform.
1 parent 8c61cd4 commit 271a3d1

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

library/std/src/fs.rs

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -624,20 +624,20 @@ impl File {
624624
self.inner.datasync()
625625
}
626626

627-
/// Acquire an exclusive advisory lock on the file. Blocks until the lock can be acquired.
627+
/// Acquire an exclusive lock on the file. Blocks until the lock can be acquired.
628628
///
629-
/// This acquires an exclusive advisory lock; no other file handle to this file may acquire
630-
/// another lock.
629+
/// This acquires an exclusive lock; no other file handle to this file may acquire another lock.
631630
///
632-
/// If this file handle/descriptor, or a clone of it, already holds an advisory lock the exact
633-
/// behavior is unspecified and platform dependent, including the possibility that it will
634-
/// deadlock. However, if this method returns, then an exclusive lock is held.
631+
/// If this file handle/descriptor, or a clone of it, already holds an lock the exact behavior
632+
/// is unspecified and platform dependent, including the possibility that it will deadlock.
633+
/// However, if this method returns, then an exclusive lock is held.
635634
///
636635
/// If the file not open for writing, it is unspecified whether this function returns an error.
637636
///
638-
/// Note, this is an advisory lock meant to interact with [`lock_shared`], [`try_lock`],
639-
/// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
640-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
637+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
638+
/// [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with other methods,
639+
/// such as [`read`] and [`write`] are platform specific, and it may or may not cause
640+
/// non-lockholders to block.
641641
///
642642
/// The lock will be released when this file (along with any other file descriptors/handles
643643
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -674,18 +674,19 @@ impl File {
674674
self.inner.lock()
675675
}
676676

677-
/// Acquire a shared (non-exclusive) advisory lock on the file. Blocks until the lock can be acquired.
677+
/// Acquire a shared (non-exclusive) lock on the file. Blocks until the lock can be acquired.
678678
///
679-
/// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but
680-
/// none may hold an exclusive lock at the same time.
679+
/// This acquires a shared lock; more than one file handle may hold a shared lock, but none may
680+
/// hold an exclusive lock at the same time.
681681
///
682-
/// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact
683-
/// behavior is unspecified and platform dependent, including the possibility that it will
684-
/// deadlock. However, if this method returns, then a shared lock is held.
682+
/// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior
683+
/// is unspecified and platform dependent, including the possibility that it will deadlock.
684+
/// However, if this method returns, then a shared lock is held.
685685
///
686-
/// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`],
687-
/// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
688-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
686+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
687+
/// [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with other methods,
688+
/// such as [`read`] and [`write`] are platform specific, and it may or may not cause
689+
/// non-lockholders to block.
689690
///
690691
/// The lock will be released when this file (along with any other file descriptors/handles
691692
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -722,24 +723,23 @@ impl File {
722723
self.inner.lock_shared()
723724
}
724725

725-
/// Try to acquire an exclusive advisory lock on the file.
726+
/// Try to acquire an exclusive lock on the file.
726727
///
727728
/// Returns `Ok(false)` if a different lock is already held on this file (via another
728729
/// handle/descriptor).
729730
///
730-
/// This acquires an exclusive advisory lock; no other file handle to this file may acquire
731-
/// another lock.
731+
/// This acquires an exclusive lock; no other file handle to this file may acquire another lock.
732732
///
733-
/// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact
734-
/// behavior is unspecified and platform dependent, including the possibility that it will
735-
/// deadlock. However, if this method returns `Ok(true)`, then it has acquired an exclusive
736-
/// lock.
733+
/// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior
734+
/// is unspecified and platform dependent, including the possibility that it will deadlock.
735+
/// However, if this method returns `Ok(true)`, then it has acquired an exclusive lock.
737736
///
738737
/// If the file not open for writing, it is unspecified whether this function returns an error.
739738
///
740-
/// Note, this is an advisory lock meant to interact with [`lock`], [`lock_shared`],
741-
/// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
742-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
739+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
740+
/// [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with other methods,
741+
/// such as [`read`] and [`write`] are platform specific, and it may or may not cause
742+
/// non-lockholders to block.
743743
///
744744
/// The lock will be released when this file (along with any other file descriptors/handles
745745
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -777,21 +777,22 @@ impl File {
777777
self.inner.try_lock()
778778
}
779779

780-
/// Try to acquire a shared (non-exclusive) advisory lock on the file.
780+
/// Try to acquire a shared (non-exclusive) lock on the file.
781781
///
782782
/// Returns `Ok(false)` if an exclusive lock is already held on this file (via another
783783
/// handle/descriptor).
784784
///
785-
/// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but
786-
/// none may hold an exclusive lock at the same time.
785+
/// This acquires a shared lock; more than one file handle may hold a shared lock, but none may
786+
/// hold an exclusive lock at the same time.
787787
///
788-
/// If this file handle, or a clone of it, already holds an advisory lock, the exact behavior is
788+
/// If this file handle, or a clone of it, already holds an lock, the exact behavior is
789789
/// unspecified and platform dependent, including the possibility that it will deadlock.
790790
/// However, if this method returns `Ok(true)`, then it has acquired a shared lock.
791791
///
792-
/// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`],
793-
/// [`try_lock`], and [`unlock`]. Its interactions with other methods, such as [`read`]
794-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
792+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
793+
/// [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with other methods,
794+
/// such as [`read`] and [`write`] are platform specific, and it may or may not cause
795+
/// non-lockholders to block.
795796
///
796797
/// The lock will be released when this file (along with any other file descriptors/handles
797798
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.

0 commit comments

Comments
 (0)