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

Function tl_release

src/foundation/mem_events.c:1548–1565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1546}
1547
1548static void tl_release(void *raw) {
1549 tl_state_t *st = (tl_state_t *)raw;
1550 if (!st || raw == TL_EXITED) {
1551 return;
1552 }
1553 st->busy = true;
1554 flush_state(st);
1555 /* Mark the slot before the memory goes: whatever the rest of the thread's
1556 * teardown allocates or frees must find the marker, neither a freed pointer
1557 * nor an empty slot that would build a new state. */
1558#ifdef _WIN32
1559 (void)TlsSetValue(g_key, TL_EXITED);
1560#else
1561 (void)pthread_setspecific(g_key, TL_EXITED);
1562#endif
1563 atomic_fetch_sub_explicit(&g_layer_threads, 1, memory_order_relaxed);
1564 vm_put(st, tl_bytes());
1565}
1566
1567/* ── phase snapshot ───────────────────────────────────────────────────
1568 * Live blocks allocated in an earlier phase are RETAINED: the question is

Callers 1

cbm_memev_thread_endFunction · 0.85

Calls 3

flush_stateFunction · 0.85
vm_putFunction · 0.85
tl_bytesFunction · 0.85

Tested by

no test coverage detected