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

Function pp_rust_shared_registry

src/pipeline/pass_parallel.c:2859–2880  ·  view source on GitHub ↗

F4: get (or lazily build ONCE) the shared all_defs Rust registry. Called by the * first worker that hits a NULL-filter rust file; later null-files reuse it. Fast * path is a lock-free atomic load; the build happens under rust_shared_mu into the * dedicated rust_shared_arena (never a shared pipeline arena from a worker thread). * Returns NULL if there are no defs (caller falls back to the per-f

Source from the content-addressed store, hash-verified

2857 * dedicated rust_shared_arena (never a shared pipeline arena from a worker thread).
2858 * Returns NULL if there are no defs (caller falls back to the per-file build). */
2859static CBMTypeRegistry *pp_rust_shared_registry(resolve_ctx_t *rc) {
2860 CBMTypeRegistry *p = atomic_load_explicit(&rc->rust_shared_reg, memory_order_acquire);
2861 if (p)
2862 return p;
2863 if (!rc->all_defs || rc->def_count <= 0)
2864 return NULL;
2865 cbm_mutex_lock(&rc->rust_shared_mu);
2866 p = atomic_load_explicit(&rc->rust_shared_reg, memory_order_relaxed);
2867 if (!p) {
2868 cbm_arena_init(&rc->rust_shared_arena);
2869 rc->rust_shared_arena_live = true;
2870 p = cbm_rust_build_cross_registry(&rc->rust_shared_arena, rc->all_defs, rc->def_count);
2871 if (p) {
2872 char sb[96];
2873 snprintf(sb, sizeof(sb), "types=%d funcs=%d", p->type_count, p->func_count);
2874 cbm_log_info("cross_lsp.rust_registry", "scale", sb);
2875 }
2876 atomic_store_explicit(&rc->rust_shared_reg, p, memory_order_release);
2877 }
2878 cbm_mutex_unlock(&rc->rust_shared_mu);
2879 return p;
2880}
2881
2882/* void*-typed adapter so the shared dispatch helper (pass_lsp_cross.c) can
2883 * borrow the lazily-built shared Rust registry without knowing resolve_ctx_t. */

Callers 1

Calls 4

cbm_mutex_lockFunction · 0.85
cbm_mutex_unlockFunction · 0.85
cbm_arena_initFunction · 0.50

Tested by

no test coverage detected