|
|
||
|---|---|---|
| .. | ||
| LICENSE | ||
| README.md | ||
| VERSION | ||
| test.scm | ||
README.md
Dot locking for files
This is an implementation of dot-locking from scsh.
Documentation
From https://scsh.net/docu/html/man-Z-H-11.html#node_sec_10.3
Copied here for convenience.
(obtain-dot-lock file-name)
Tries to obtain the lock for file-name. If the file is already locked, the thread sleeps for interval seconds (default is 1) before it retries. If the lock cannot be obtained after retry-number attempts, the procedure returns #f, other- wise #t. The default value of retry-number is #f which corresponds to an infinite number of retires. If stale-time is non-#f, it specifies the minimum age a lock may have (in seconds) before it is considered stale. Obtain-dot-lock attempts to delete stale locks. If it was succcessful obtaining a lock after breaking it, obtain-dot-lock returns broken. If stale-time is #f, obtain-dot-lock never considers a lock stale. The default for stale-time is 300. Note that it is possible that obtain-dot-lock breaks a lock but never- theless fails to obtain it otherwise. If it is necessary to handle this case specially, use break-dot-lock directly (see below) rather than specifying a non-#f stale-time
(break-dot-lock file-name)
Breaks the lock for file-name if one exists. Note that breaking a lock does not imply a subsequent obtain-dot-lock will succeed, as an- other party may have acquired the lock between break-dot-lock and obtain-dot-lock.
(release-dot-lock file-name)
Releases the lock for file-name. On success, release-dot-lock returns #t, otherwise #f. Note that this procedure can also be used to break the lock for file-name.
(with-dot-lock* file-name thunk) (with-dot-lock file-name body ...)
The procedure with-dot-lock* obtains the requested lock, and then calls (thunk). When thunk returns, the lock is released. A non-local exit (e.g., throwing to a saved continuation or raising an exception) also causes the lock to be released. After a normal return from thunk, its return values are returned by with-dot-lock*. The with-dot-lock special form is equivalent syntac- tic sugar.