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:42–51  ·  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

40/* The CLI may install the sink more than once in one process (notably tests),
41 * so keep one process-lifetime mutex rather than destroying it at fini. */
42static void progress_sink_mutex_ensure(void) {
43 int expected = LOCK_UNINITIALIZED;
44 if (atomic_compare_exchange_strong_explicit(&s_sink_mutex_state, &expected, LOCK_INITIALIZING,
45 memory_order_acq_rel, memory_order_acquire)) {
46 cbm_mutex_init(&s_sink_mutex);
47 atomic_store_explicit(&s_sink_mutex_state, LOCK_READY, memory_order_release);
48 return;
49 }
50 while (atomic_load_explicit(&s_sink_mutex_state, memory_order_acquire) != LOCK_READY) {}
51}
52
53bool cbm_cli_output_flags_parse(int *argc, char **argv, cbm_cli_output_flags_t *flags, char *error,
54 size_t error_size) {

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