21 stable releases (12 major)

new 15.0.1 Nov 24, 2024
14.0.0 May 22, 2024
13.1.1 Mar 14, 2024
12.0.1 Dec 30, 2023
3.0.2 Feb 17, 2023

#68 in Concurrency

Download history 109726/week @ 2024-08-04 108454/week @ 2024-08-11 107161/week @ 2024-08-18 107872/week @ 2024-08-25 117119/week @ 2024-09-01 118534/week @ 2024-09-08 108062/week @ 2024-09-15 114643/week @ 2024-09-22 115984/week @ 2024-09-29 106371/week @ 2024-10-06 120141/week @ 2024-10-13 113706/week @ 2024-10-20 111776/week @ 2024-10-27 117504/week @ 2024-11-03 127548/week @ 2024-11-10 116041/week @ 2024-11-17

482,967 downloads per month
Used in 263 crates (4 directly)

MIT/Apache

81KB
1.5K SLoC

Use lock-files in the way git does with auto-cleanup being the most notable feature.

  • writable lock files that can be committed to atomically replace the resource they lock
  • read-only markers that lock a resource without the intend to overwrite it
  • auto-removal of the lockfiles and intermediate directories on drop or on signal

lib.rs:

git-style registered lock files to make altering resources atomic.

In this model, reads are always atomic and can be performed directly while writes are facilitated by the locking mechanism implemented here. Locks are acquired atomically, then written to, to finally atomically overwrite the actual resource.

Lock files are wrapped gix-tempfile-handles and add the following:

  • consistent naming of lock files
  • block the thread (with timeout) or fail immediately if a lock cannot be obtained right away
  • commit lock files to atomically put them into the location of the originally locked file

Limitations

  • All limitations of gix-tempfile apply. A highlight of such a limitation is resource leakage which results in them being permanently locked unless there is user-intervention.
  • As the lock file is separate from the actual resource, locking is merely a convention rather than being enforced.

Dependencies

~3–12MB
~181K SLoC