module Nfs:an implementation neutral NFS lock file scheme that relies on the atomicity of link and rename over NFS (see NFS Illustrated, atomicity for more information). There are a few caveats compared to local file locks:sig
..end
val create : ?message:string -> string -> bool
lock ?message path
tries to lock the file at path
by creating two new files
path
.nfs_lock and path
.nfs_lock.msg. path
.nfs_lock will be a hard link to
path
and path
.nfs_lock.msg will contain message
(caller's hostname and pid by
default). This lock WILL NOT be released when the calling program exits. You MUST
call unlock.val create_exn : ?message:string -> string -> unit
lock_exn ?message path
like lock, but throws an exception when it fails to obtain
the lockval blocking_create : ?message:string -> string -> unit
lock_blocking ?message path
like lock, but sleeps for 1 second between lock
attempts and does not return until it succeedsval unlock : string -> unit
unlock path
unlocks a file locked by some version of lock. There is no protection
provided to stop you from unlocking a file you have not lockedval critical_section : ?message:string -> string -> f:(unit -> 'a) -> 'a
critical_section ?message path ~f
wrap function f
(including exceptions escaping
it) by first locking (using Lock_file.Nfs.create_exn
) and then unlocking the given lock
file.