module Nfs:sig
..end
There are a few caveats compared to local file locks:
val create : ?message:string -> string -> bool
lock ?message path
tries to create and lock the file at path
by creating a hard
link to path
.nfs_lock. The contents of path will be replaced with message
,
which will be the caller's hostname:pid by default.
Efforts will be made to release this lock when the calling program exits. But there
is no guarantee that this will occur under some types of program crash
val create_exn : ?message:string -> string -> unit
create_exn ?message path
like create, but throws an exception when it fails to
obtain the lockval blocking_create : ?message:string -> string -> unit
blocking_create ?message path
like create, but sleeps for 1 second between lock
attempts and does not return until it succeedsval 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.val get_hostname_and_pid : string -> (string * int) option
get_hostname_and_pid path
reads the lock file at path
and returns the hostname
and path in the file if it can be parsed.