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

Function cbm_destroy_thread_parser

internal/cbm/cbm.c:1009–1039  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1007}
1008
1009void cbm_destroy_thread_parser(void) {
1010 // Full cleanup: delete the parser. Call on worker thread exit.
1011 if (tl_parser) {
1012 ts_parser_delete(tl_parser);
1013 tl_parser = NULL;
1014 tl_parser_lang = CBM_LANG_COUNT;
1015 }
1016 if (tl_cursor_live) {
1017 ts_tree_cursor_delete(&tl_cursor);
1018 tl_cursor_live = false;
1019 }
1020 if (tl_cursor_pool) {
1021 bool busy = false;
1022 for (int d = 0; d < CURSOR_POOL_DEPTH; d++) {
1023 /* a busy slot belongs to a walk still on this stack: leave it */
1024 if (tl_cursor_pool->state[d] == CURSOR_LIVE) {
1025 ts_tree_cursor_delete(&tl_cursor_pool->cursors[d]);
1026 tl_cursor_pool->state[d] = 0;
1027 } else if (tl_cursor_pool->state[d] & CURSOR_BUSY) {
1028 busy = true;
1029 }
1030 }
1031 /* Outstanding leases point INTO this block, so it is only released once
1032 * no walk still holds a slot. */
1033 if (!busy) {
1034 cbm_free(CBM_MEM_CLASS_OTHER, tl_cursor_pool);
1035 tl_cursor_pool = NULL;
1036 }
1037 }
1038 cbm_ts_field_cache_release_thread();
1039}
1040
1041void cbm_shutdown(void) {
1042 // Clean up thread-local parser for the calling thread.

Callers 9

cbm_shutdownFunction · 0.85
k8s_prep_workerFunction · 0.85
extract_workerFunction · 0.85
cbm_parallel_extract_exFunction · 0.85
resolve_workerFunction · 0.85
run_sequential_pipelineFunction · 0.85
test_mem.cFile · 0.85
dm_extract_threadFunction · 0.85

Calls 2

cbm_freeFunction · 0.85

Tested by 1

dm_extract_threadFunction · 0.68