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:3973–3994  ·  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

3971 * dedicated rust_shared_arena (never a shared pipeline arena from a worker thread).
3972 * Returns NULL if there are no defs (caller falls back to the per-file build). */
3973static CBMTypeRegistry *pp_rust_shared_registry(resolve_ctx_t *rc) {
3974 CBMTypeRegistry *p = atomic_load_explicit(&rc->rust_shared_reg, memory_order_acquire);
3975 if (p)
3976 return p;
3977 if (!rc->all_defs || rc->def_count <= 0)
3978 return NULL;
3979 cbm_mutex_lock(&rc->rust_shared_mu);
3980 p = atomic_load_explicit(&rc->rust_shared_reg, memory_order_relaxed);
3981 if (!p) {
3982 cbm_arena_init(&rc->rust_shared_arena);
3983 rc->rust_shared_arena_live = true;
3984 p = cbm_rust_build_cross_registry(&rc->rust_shared_arena, rc->all_defs, rc->def_count);
3985 if (p) {
3986 char sb[96];
3987 snprintf(sb, sizeof(sb), "types=%d funcs=%d", p->type_count, p->func_count);
3988 cbm_log_info("cross_lsp.rust_registry", "scale", sb);
3989 }
3990 atomic_store_explicit(&rc->rust_shared_reg, p, memory_order_release);
3991 }
3992 cbm_mutex_unlock(&rc->rust_shared_mu);
3993 return p;
3994}
3995
3996/* void*-typed adapter so the shared dispatch helper (pass_lsp_cross.c) can
3997 * 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