MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_watcher_run

Function cbm_watcher_run

src/watcher/watcher.c:718–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

716}
717
718int cbm_watcher_run(cbm_watcher_t *w, int base_interval_ms) {
719 if (!w) {
720 return CBM_NOT_FOUND;
721 }
722 if (base_interval_ms <= 0) {
723 base_interval_ms = POLL_BASE_MS;
724 }
725
726 cbm_log_info("watcher.start", "interval_ms", base_interval_ms > 999 ? "multi-sec" : "fast");
727
728 while (!atomic_load(&w->stopped)) {
729 cbm_watcher_poll_once(w);
730
731 /* Sleep in small increments to allow responsive shutdown */
732 int slept = 0;
733 while (slept < base_interval_ms && !atomic_load(&w->stopped)) {
734 int chunk = base_interval_ms - slept;
735 if (chunk > SLEEP_CHUNK_MS) {
736 chunk = SLEEP_CHUNK_MS;
737 }
738 cbm_usleep((unsigned)chunk * CBM_MSEC_PER_SEC);
739 slept += chunk;
740 }
741 }
742
743 cbm_log_info("watcher.stop");
744 return 0;
745}

Callers 2

watcher_threadFunction · 0.85
test_watcher.cFile · 0.85

Calls 1

cbm_watcher_poll_onceFunction · 0.85

Tested by

no test coverage detected