Up

module Lock_file

: sig

Async.Lock_file is a wrapper that provides Async equivalents for Core.Lock_file.

#
val create : ?message:string -> ?close_on_exec:bool -> ?unlink_on_exit:bool -> string -> bool Import.Deferred.t

create ?message path tries to create a file at path containing the text message, pid if none provided. It returns true on success, false on failure. Note: there is no way to release the lock or the fd created inside! It will only be released when the process dies.

#
val create_exn : ?message:string -> ?close_on_exec:bool -> ?unlink_on_exit:bool -> string -> unit Import.Deferred.t

create_exn ?message path is like create except that it throws an exception on failure instead of returning a boolean value

#
val waiting_create : ?abort:unit Import.Deferred.t -> ?message:string -> ?close_on_exec:bool -> ?unlink_on_exit:bool -> string -> unit Import.Deferred.t

waiting_create path repeatedly tries to lock path, becoming determined when path is locked or raising when abort becomes determined. Similar to Core.Std.Lock_file.blocking_create.

#
val is_locked : string -> bool Import.Deferred.t

is_locked path returns true when the file at path exists and is locked, false otherwise.

#
module Nfs : sig

Nfs has analogs of functions in [root:Core].Lock_file.Nfs; see there for documentation. In addition to adding Deferred's, blocking_create was renamed waiting_create to avoid the impression that it blocks Async.

#
val create : ?message:string -> string -> unit Import.Deferred.Or_error.t
#
val create_exn : ?message:string -> string -> unit Import.Deferred.t
#
val waiting_create : ?abort:unit Import.Deferred.t -> ?message:string -> string -> unit Import.Deferred.t
#
val unlock_exn : string -> unit Import.Deferred.t
#
val unlock : string -> unit Import.Deferred.Or_error.t
#
val critical_section : ?message:string -> string -> abort:unit Import.Deferred.t -> f:(unit -> 'a Import.Deferred.t) -> 'a Import.Deferred.t
#
val get_hostname_and_pid : string -> (string * Core.Std.Pid.t) option Import.Deferred.t
#
val get_message : string -> string option Import.Deferred.t
end
end