123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596(*
* Copyright (c) 2013-2022 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)moduletypeS=sig(** {1 Watch Helpers} *)typekey(** The type for store keys. *)typevalue(** The type for store values. *)typewatch(** The type for watch handlers. *)typet(** The type for watch state. *)valstats:t->int*int(** [stats t] is a tuple [(k,a)] represeting watch stats. [k] is the number of
single key watchers for the store [t] and [a] the number of global
watchers for [t]. *)valnotify:t->key->valueoption->unitLwt.t(** Notify all listeners in the given watch state that a key has changed, with
the new value associated to this key. [None] means the key has been
removed. *)valv:unit->t(** Create a watch state. *)valclear:t->unitLwt.t(** Clear all register listeners in the given watch state. *)valwatch_key:t->key->?init:value->(valueDiff.t->unitLwt.t)->watchLwt.t(** Watch a given key for changes. More efficient than {!val-watch}. *)valwatch:t->?init:(key*value)list->(key->valueDiff.t->unitLwt.t)->watchLwt.t(** Add a watch handler. To watch a specific key, use {!watch_key} which is
more efficient. *)valunwatch:t->watch->unitLwt.t(** Remove a watch handler. *)vallisten_dir:t->string->key:(string->keyoption)->value:(key->valueoptionLwt.t)->(unit->unitLwt.t)Lwt.t(** Register a thread looking for changes in the given directory and return a
function to stop watching and free up resources. *)endmoduletypeSigs=sigmoduletypeS=S(** The signature for watch helpers. *)valworkers:unit->int(** [workers ()] is the number of background worker threads managing event
notification currently active. *)typehook=int->string->(string->unitLwt.t)->(unit->unitLwt.t)Lwt.t(** The type for watch hooks. *)valnone:hook(** [none] is the hooks which asserts false. *)valset_listen_dir_hook:hook->unit(** Register a function which looks for file changes in a directory and return
a function to stop watching. It is probably best to use
{!Irmin_watcher.hook} there. By default, it uses {!none}. *)(** [Make] builds an implementation of watch helpers. *)moduleMake(K:Type.S)(V:Type.S):Swithtypekey=K.tandtypevalue=V.tend