Cross-platform filesystem watcher for MoonBit: FSEvents on macOS, inotify on Linux, polling fallback elsewhere.
Dependencies
| Target / OS | Backend | Latency |
|---|---|---|
| native / macOS | FSEvents (via dlopen, no -framework link dep) | ~50 ms drain interval, OS-driven detection |
| native / Linux | inotify | ~50 ms drain interval, kernel-driven detection |
| native / Windows | ReadDirectoryChangesW (per-root HANDLE + OVERLAPPED, single reader thread via WaitForMultipleObjects) | ~50 ms drain interval, kernel-driven detection |
| native / other | Polling (mtime + size fingerprint) | ~500 ms scan interval |
| js / Node | fs.watch per root with recursive: true | ~50 ms drain interval, Node event-loop-driven detection |
async fn watch_src() -> Unit raise {
let watcher = @fswatch.start(["src", "Taskfile.pkl"])
defer watcher.close()
for ;; {
let events = watcher.next()
if events.length() == 0 { break }
for e in events {
println("\{e.kind} \{e.path}")
}
}
}pub struct Watcher {
// private fields
}Cross-platform filesystem watcher for MoonBit: FSEvents on macOS, inotify on Linux, polling fallback elsewhere.
Dependencies