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

Function progress_sink_mutex_ensure

src/cli/progress_sink.c:39–48  ·  view source on GitHub ↗

The CLI may install the sink more than once in one process (notably tests), * so keep one process-lifetime mutex rather than destroying it at fini. */

Source from the content-addressed store, hash-verified

37/* The CLI may install the sink more than once in one process (notably tests),
38 * so keep one process-lifetime mutex rather than destroying it at fini. */
39static void progress_sink_mutex_ensure(void) {
40 int expected = LOCK_UNINITIALIZED;
41 if (atomic_compare_exchange_strong_explicit(&s_sink_mutex_state, &expected, LOCK_INITIALIZING,
42 memory_order_acq_rel, memory_order_acquire)) {
43 cbm_mutex_init(&s_sink_mutex);
44 atomic_store_explicit(&s_sink_mutex_state, LOCK_READY, memory_order_release);
45 return;
46 }
47 while (atomic_load_explicit(&s_sink_mutex_state, memory_order_acquire) != LOCK_READY) {}
48}
49
50bool cbm_cli_progress_enabled(bool explicitly_requested, bool stderr_is_tty) {
51 return explicitly_requested || stderr_is_tty;

Callers 3

cbm_progress_sink_initFunction · 0.85
cbm_progress_sink_finiFunction · 0.85
cbm_progress_sink_fnFunction · 0.85

Calls 1

cbm_mutex_initFunction · 0.85

Tested by

no test coverage detected