package async

  1. Overview
  2. Docs
type t

Flock has async analogues of functions in Lock_file_blocking.Flock; see there for documentation.

Additionally, here we:

  • catch unix exceptions, packaging them as Deferred.Or_error.t
  • implement abortable waiting versions based on polling
val lock_exn : ?lock_owner_uid:int -> lock_path:string -> unit -> [ `Somebody_else_took_it | `We_took_it of t ] Async.Deferred.t

lock_exn ?lock_owner_uid ~lock_path () Attempt to take the lock at lock_path. It optionally also sets the owner id to lock_owner_uid.

val lock : ?lock_owner_uid:int -> lock_path:string -> unit -> [ `Somebody_else_took_it | `We_took_it of t ] Async.Deferred.Or_error.t
val unlock_exn : t -> unit Async.Deferred.t
val unlock : t -> unit Async.Deferred.Or_error.t
val wait_for_lock_exn : ?abort:unit Async.Deferred.t -> ?lock_owner_uid:int -> lock_path:string -> unit -> t Async.Deferred.t

wait_for_lock_exn ?abort ?lock_owner_uid ~lock_path () Wait for the lock, giving up once abort becomes determined. It optionally also sets the owner id to lock_owner_uid.

val wait_for_lock : ?abort:unit Async.Deferred.t -> ?lock_owner_uid:int -> lock_path:string -> unit -> t Async.Deferred.Or_error.t

See wait_for_lock_exn

OCaml

Innovation. Community. Security.