package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This is a bit better than Mkdir and is very likely to be compatible: it lets you atomically write the owner of the lock into the symlink, it's used both by emacs and hg, and it's supposed to work on nfs.

type t
val lock_exn : lock_path:string -> metadata:string -> [ `We_took_it of t | `Somebody_else_took_it of string Core.Or_error.t ]

metadata should include some information to help the user identify the lock holder. Usually it's the pid of the holder, but if you use this across a fork or take the lock multiple times in the same program, then some extra information could be useful. This string will be saved as the target of a (usually dangling) symbolic link at path lock_path.

`Somebody_else_took_it returns the metadata of the process who took it or an error if that can't be determined (for example: they released the lock by the time we tried to inspect it)

Raises an exception if taking the lock fails for any reason other than somebody else holding the lock.

val unlock_exn : t -> unit
OCaml

Innovation. Community. Security.