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

Function cbm_parallel_for

src/pipeline/worker_pool.c:185–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183/* ── Public API ──────────────────────────────────────────────────── */
184
185void cbm_parallel_for(int count, cbm_parallel_fn fn, void *ctx, cbm_parallel_for_opts_t opts) {
186 if (count <= 0 || !fn) {
187 return;
188 }
189
190 /* Determine worker count */
191 int nworkers = opts.max_workers;
192 if (nworkers <= 0) {
193 nworkers = cbm_default_worker_count(true);
194 }
195 if (nworkers < WP_MIN) {
196 nworkers = SKIP_ONE;
197 }
198
199 /* Serial fallback: single worker or trivially small workload */
200 if (nworkers <= WP_MIN || count <= WP_MIN) {
201 run_serial(count, fn, ctx);
202 return;
203 }
204
205#if defined(CBM_MEMWASTE) && CBM_MEMWASTE
206 if (cbm_memev_enabled()) {
207 run_pthreads_counted(count, fn, ctx, nworkers, __builtin_return_address(0));
208 return;
209 }
210#endif
211 run_pthreads(count, fn, ctx, nworkers);
212}

Callers 15

finalize_build_sourcesFunction · 0.85
finalize_pass1Function · 0.85
finalize_pass2Function · 0.85
phase1b_decode_and_buildFunction · 0.85
phase2_tokenizeFunction · 0.85
phase5_lsh_buildFunction · 0.85
phase6a_score_candidatesFunction · 0.85
phase6c_doc_sectionsFunction · 0.85
cbm_pipeline_pass_k8sFunction · 0.85

Calls 5

cbm_default_worker_countFunction · 0.85
run_serialFunction · 0.85
cbm_memev_enabledFunction · 0.85
run_pthreads_countedFunction · 0.85
run_pthreadsFunction · 0.85

Tested by

no test coverage detected