#ifndef BOUNDED_PROLIFIC_SCHEDULER_HPP
#define BOUNDED_PROLIFIC_SCHEDULER_HPP

#include <sys/types.h>

// Task signature:
//   taskId      -> which task this worker is executing
//   workerId    -> logical worker index [0..workerCount-1]
//   workerCount -> total number of workers
//   context     -> shared/custom context pointer
using scheduler_task_fn = void (*)(int taskId, int workerId, int workerCount, void* context);

// Runs totalTasks tasks using at most workerCount child processes.
// Each child executes taskIds:
//   workerId, workerId + workerCount, workerId + 2*workerCount, ...
//
// Returns 0 on success, -1 on failure.
int run_bounded_prolific_scheduler(
    int totalTasks,
    int workerCount,
    scheduler_task_fn taskFn,
    void* context,
    bool enableAffinity = true
);

// Utility if you want to reuse it elsewhere
bool bind_process_to_cpu_scheduler(int cpuId);

#endif
