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

Function cbm_work_note_path

src/foundation/mem_events.c:1399–1432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1397}
1398
1399void cbm_work_note_path(cbm_work_kind_t kind, void *site, const char *path, bool failed) {
1400 if (!cbm_memev_enabled()) {
1401 return;
1402 }
1403 tl_state_t *st = tl_get();
1404 if (!st || st->busy) {
1405 return;
1406 }
1407 st->busy = true;
1408 uint64_t h = mix(path_hash(path) ^ ((uint64_t)kind << 58)) | 1U;
1409 uint64_t repeat = 0;
1410 uint32_t idx = (uint32_t)(h & (MEMEV_PATH_CAP - 1));
1411 for (uint32_t probe = 0; probe < MEMEV_PATH_CAP; probe++) {
1412 uint64_t seen = atomic_load_explicit(&g_path_hashes[idx], memory_order_relaxed);
1413 if (seen == h) {
1414 repeat = 1;
1415 break;
1416 }
1417 if (seen == 0) {
1418 uint64_t expect = 0;
1419 if (atomic_compare_exchange_strong_explicit(
1420 &g_path_hashes[idx], &expect, h, memory_order_relaxed, memory_order_relaxed)) {
1421 break;
1422 }
1423 if (expect == h) {
1424 repeat = 1;
1425 break;
1426 }
1427 }
1428 idx = (idx + 1) & (MEMEV_PATH_CAP - 1);
1429 }
1430 work_add(st, kind, (uintptr_t)site, 0, failed ? 1 : 0, 0, repeat);
1431 st->busy = false;
1432}
1433
1434void cbm_work_note_ht(cbm_work_kind_t kind, void *site, const void *table, const char *key,
1435 uint64_t generation, bool hit) {

Callers 15

openFunction · 0.85
statFunction · 0.85
lstatFunction · 0.85
fopenFunction · 0.85
opendirFunction · 0.85
__wrap_openFunction · 0.85
__wrap_open64Function · 0.85
__wrap___open_2Function · 0.85
__wrap___open64_2Function · 0.85
__wrap_statFunction · 0.85
__wrap_lstatFunction · 0.85
__wrap_fopenFunction · 0.85

Calls 5

cbm_memev_enabledFunction · 0.85
tl_getFunction · 0.85
mixFunction · 0.85
path_hashFunction · 0.85
work_addFunction · 0.85

Tested by

no test coverage detected