worker_thread

Function worker_thread 

Source
pub fn worker_thread(
    worker_id: usize,
    num_workers: usize,
    _queue: Arc<BoundedPriorityQueue<Task>>,
    barrier: Arc<Barrier>,
    shared: Arc<SharedCompressorState>,
)
Expand description

Worker thread main loop

This matches C++ AGC’s worker lambda (agc_compressor.cpp:1099-1270):

v_threads.emplace_back([&, i, n_t]() {
    auto zstd_cctx = ZSTD_createCCtx();
    auto zstd_dctx = ZSTD_createDCtx();
    uint32_t thread_id = i;

    while(true) {
        task_t task;
        auto q_res = pq_contigs_desc_working->PopLarge(task);
        // ... process task ...
    }

    ZSTD_freeCCtx(zstd_cctx);
    ZSTD_freeDCtx(zstd_dctx);
});

§Arguments

  • worker_id - Thread ID (0 to num_workers-1)
  • queue - Priority queue for pulling tasks
  • barrier - Synchronization barrier for registration/new_splitters stages
  • shared - Shared state accessible to all workers