From 745bc9d77eca6149bdd2d54063e2909b57a18baa Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 6 Nov 2019 11:45:57 +0900 Subject: [PATCH 1/3] Fix list of modules in dune file The polling module is only used conditionally. It does not need to be included. Signed-off-by: Rudi Grinberg --- src/dune | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dune b/src/dune index 5c34994..cbc7404 100644 --- a/src/dune +++ b/src/dune @@ -1,6 +1,6 @@ (library (name irmin_watcher) - (modules core hook backend polling irmin_watcher) + (modules core hook backend irmin_watcher) (public_name irmin-watcher) (c_names realpath) (libraries fmt lwt logs astring From 0bfdada4b4143bc3e52ce84965e26cad5efd080a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 6 Nov 2019 17:10:31 +0900 Subject: [PATCH 2/3] Use better naming convention for select Now we no longer need to include a `modules` field Signed-off-by: Rudi Grinberg --- src/{fsevents.ml => backend.fsevents.ml} | 0 src/{fsevents.mli => backend.fsevents.mli} | 0 src/{inotify.ml => backend.inotify.ml} | 0 src/{inotify.mli => backend.inotify.mli} | 0 src/{polling.ml => backend.polling.ml} | 0 src/{polling.mli => backend.polling.mli} | 0 src/dune | 13 ++++++------- 7 files changed, 6 insertions(+), 7 deletions(-) rename src/{fsevents.ml => backend.fsevents.ml} (100%) rename src/{fsevents.mli => backend.fsevents.mli} (100%) rename src/{inotify.ml => backend.inotify.ml} (100%) rename src/{inotify.mli => backend.inotify.mli} (100%) rename src/{polling.ml => backend.polling.ml} (100%) rename src/{polling.mli => backend.polling.mli} (100%) diff --git a/src/fsevents.ml b/src/backend.fsevents.ml similarity index 100% rename from src/fsevents.ml rename to src/backend.fsevents.ml diff --git a/src/fsevents.mli b/src/backend.fsevents.mli similarity index 100% rename from src/fsevents.mli rename to src/backend.fsevents.mli diff --git a/src/inotify.ml b/src/backend.inotify.ml similarity index 100% rename from src/inotify.ml rename to src/backend.inotify.ml diff --git a/src/inotify.mli b/src/backend.inotify.mli similarity index 100% rename from src/inotify.mli rename to src/backend.inotify.mli diff --git a/src/polling.ml b/src/backend.polling.ml similarity index 100% rename from src/polling.ml rename to src/backend.polling.ml diff --git a/src/polling.mli b/src/backend.polling.mli similarity index 100% rename from src/polling.mli rename to src/backend.polling.mli diff --git a/src/dune b/src/dune index cbc7404..6fcb235 100644 --- a/src/dune +++ b/src/dune @@ -1,14 +1,13 @@ (library (name irmin_watcher) - (modules core hook backend irmin_watcher) (public_name irmin-watcher) (c_names realpath) (libraries fmt lwt logs astring (select backend.ml from - (osx-cf.lwt osx-fsevents.lwt -> fsevents.ml) - (inotify.lwt -> inotify.ml) - (lwt.unix -> polling.ml)) + (osx-cf.lwt osx-fsevents.lwt -> backend.fsevents.ml) + (inotify.lwt -> backend.inotify.ml) + (lwt.unix -> backend.polling.ml)) (select backend.mli from - (osx-cf.lwt osx-fsevents.lwt -> fsevents.mli) - (inotify.lwt -> inotify.mli) - (lwt.unix -> polling.mli)))) + (osx-cf.lwt osx-fsevents.lwt -> backend.fsevents.mli) + (inotify.lwt -> backend.inotify.mli) + (lwt.unix -> backend.polling.mli)))) From 76e2bdf929c55890f575e0a9ed50aabac706527d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 8 Nov 2019 00:17:36 +0900 Subject: [PATCH 3/3] Always have a polling module Signed-off-by: Rudi Grinberg --- src/backend.polling.ml | 41 +---------------------------------------- src/backend.polling.mli | 38 +------------------------------------- src/polling.ml | 40 ++++++++++++++++++++++++++++++++++++++++ src/polling.mli | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 77 deletions(-) create mode 100644 src/polling.ml create mode 100644 src/polling.mli diff --git a/src/backend.polling.ml b/src/backend.polling.ml index 6c0be95..3f52be8 100644 --- a/src/backend.polling.ml +++ b/src/backend.polling.ml @@ -1,40 +1 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2016 Thomas Gazagnaire. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - %%NAME%% %%VERSION%% - ---------------------------------------------------------------------------*) - -open Lwt.Infix - -let src = Logs.Src.create "irw-polling" ~doc:"Irmin watcher using using polling" -module Log = (val Logs.src_log src : Logs.LOG) - -let with_delay delay = - Log.info (fun l -> l "Polling mode"); - let wait_for_changes () = Lwt_unix.sleep delay >|= fun () -> `Unknown in - Core.create (fun dir -> Hook.v ~wait_for_changes ~dir) - -let mode = `Polling - -let v = - Log.info (fun l -> l "Polling mode"); - let wait_for_changes () = - Lwt_unix.sleep !Core.default_polling_time >|= fun () -> `Unknown - in - Core.create (fun dir -> Hook.v ~wait_for_changes ~dir) - -(*--------------------------------------------------------------------------- - Copyright (c) 2016 Thomas Gazagnaire - - Permission to use, copy, modify, and/or 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. - ---------------------------------------------------------------------------*) +include Polling diff --git a/src/backend.polling.mli b/src/backend.polling.mli index e61ed19..09b9a35 100644 --- a/src/backend.polling.mli +++ b/src/backend.polling.mli @@ -1,37 +1 @@ -(*--------------------------------------------------------------------------- - Copyright (c) 2016 Thomas Gazagnaire. All rights reserved. - Distributed under the ISC license, see terms at the end of the file. - %%NAME%% %%VERSION%% - ---------------------------------------------------------------------------*) - -(** Active polling backend for Irmin watchers. - - {e %%VERSION%% — {{:%%PKG_HOMEPAGE%% }homepage}} *) - -open Core - -val with_delay: float -> t -(** [with_delay delay id p f] is the hook calling [f] everytime a - sub-path of [p] is modified. Return a function to call to remove - the hook. Active polling is done every [delay] seconds. *) - -val v: t -(** [v] is [with_delay !default_polling_time]. *) - -val mode: [`Polling] - -(*--------------------------------------------------------------------------- - Copyright (c) 2016 Thomas Gazagnaire - - Permission to use, copy, modify, and/or 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. - ---------------------------------------------------------------------------*) +include module type of struct include Polling end diff --git a/src/polling.ml b/src/polling.ml new file mode 100644 index 0000000..6c0be95 --- /dev/null +++ b/src/polling.ml @@ -0,0 +1,40 @@ +(*--------------------------------------------------------------------------- + Copyright (c) 2016 Thomas Gazagnaire. All rights reserved. + Distributed under the ISC license, see terms at the end of the file. + %%NAME%% %%VERSION%% + ---------------------------------------------------------------------------*) + +open Lwt.Infix + +let src = Logs.Src.create "irw-polling" ~doc:"Irmin watcher using using polling" +module Log = (val Logs.src_log src : Logs.LOG) + +let with_delay delay = + Log.info (fun l -> l "Polling mode"); + let wait_for_changes () = Lwt_unix.sleep delay >|= fun () -> `Unknown in + Core.create (fun dir -> Hook.v ~wait_for_changes ~dir) + +let mode = `Polling + +let v = + Log.info (fun l -> l "Polling mode"); + let wait_for_changes () = + Lwt_unix.sleep !Core.default_polling_time >|= fun () -> `Unknown + in + Core.create (fun dir -> Hook.v ~wait_for_changes ~dir) + +(*--------------------------------------------------------------------------- + Copyright (c) 2016 Thomas Gazagnaire + + Permission to use, copy, modify, and/or 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. + ---------------------------------------------------------------------------*) diff --git a/src/polling.mli b/src/polling.mli new file mode 100644 index 0000000..e61ed19 --- /dev/null +++ b/src/polling.mli @@ -0,0 +1,37 @@ +(*--------------------------------------------------------------------------- + Copyright (c) 2016 Thomas Gazagnaire. All rights reserved. + Distributed under the ISC license, see terms at the end of the file. + %%NAME%% %%VERSION%% + ---------------------------------------------------------------------------*) + +(** Active polling backend for Irmin watchers. + + {e %%VERSION%% — {{:%%PKG_HOMEPAGE%% }homepage}} *) + +open Core + +val with_delay: float -> t +(** [with_delay delay id p f] is the hook calling [f] everytime a + sub-path of [p] is modified. Return a function to call to remove + the hook. Active polling is done every [delay] seconds. *) + +val v: t +(** [v] is [with_delay !default_polling_time]. *) + +val mode: [`Polling] + +(*--------------------------------------------------------------------------- + Copyright (c) 2016 Thomas Gazagnaire + + Permission to use, copy, modify, and/or 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. + ---------------------------------------------------------------------------*)