| 1091 | /* ── Watcher lifecycle ──────────────────────────────────────────── */ |
| 1092 | |
| 1093 | cbm_watcher_t *cbm_watcher_new(cbm_store_t *store, cbm_index_fn index_fn, void *user_data) { |
| 1094 | cbm_watcher_t *w = calloc(CBM_ALLOC_ONE, sizeof(*w)); |
| 1095 | if (!w) { |
| 1096 | return NULL; |
| 1097 | } |
| 1098 | w->store = store; |
| 1099 | w->index_fn = index_fn; |
| 1100 | w->user_data = user_data; |
| 1101 | w->projects = cbm_ht_create(CBM_SZ_32); |
| 1102 | if (!w->projects) { |
| 1103 | free(w); |
| 1104 | return NULL; |
| 1105 | } |
| 1106 | cbm_mutex_init(&w->projects_lock); |
| 1107 | cbm_mutex_init(&w->coordination_lock); |
| 1108 | atomic_init(&w->stopped, 0); |
| 1109 | atomic_init(&w->running, false); |
| 1110 | atomic_init(&w->poll_non_git, false); |
| 1111 | return w; |
| 1112 | } |
| 1113 | |
| 1114 | void cbm_watcher_set_poll_non_git(cbm_watcher_t *w, bool enabled) { |
| 1115 | if (w) { |