Skip to content

Commit

Permalink
Fix fsevents loop
Browse files Browse the repository at this point in the history
  • Loading branch information
clecat committed May 15, 2024
1 parent 423e860 commit 9b83ce7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/backend.fsevents.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ let start_runloop dir =
let stream = Fsevents_lwt.stream watcher in
let event_stream = Fsevents_lwt.event_stream watcher in
let _scheduler =
Lwt_eio.run_lwt @@ fun () ->
Lwt_eio.run_lwt_in_main @@ fun () ->
Cf_lwt.RunLoop.run_thread (fun runloop ->
Fsevents.schedule_with_run_loop event_stream runloop run_loop_mode;
if not (Fsevents.start event_stream) then
prerr_endline "failed to start FSEvents stream")
in
(* FIXME: should probably do something with the scheduler *)
let stop_scheduler () =
(Lwt_eio.run_lwt @@ fun () -> Fsevents_lwt.flush watcher);
(Lwt_eio.run_lwt_in_main @@ fun () -> Fsevents_lwt.flush watcher);
Fsevents_lwt.stop watcher;
Fsevents_lwt.invalidate watcher;
Fsevents_lwt.release watcher
Expand All @@ -44,7 +44,7 @@ let listen ~sw stream fn =
fn @@ path)
stream
in
Core.stoppable ~sw (fun () -> Lwt_eio.run_lwt iter)
Core.stoppable ~sw (fun () -> Lwt_eio.run_lwt_in_main iter)

(* Note: we use FSevents to detect any change, and we re-read the full
tree on every change (so very similar to active polling, but
Expand All @@ -64,7 +64,7 @@ let v ~sw =
events := List.rev t;
Lwt.return (`File h)
in
let wait_for_changes () = Lwt_eio.run_lwt wait_for_changes in
let wait_for_changes () = Lwt_eio.run_lwt_in_main wait_for_changes in
let unlisten =
listen ~sw stream (fun path ->
events := path :: !events;
Expand Down

0 comments on commit 9b83ce7

Please sign in to comment.