run-command API: have "run_processes_parallel{,_tr2}()" return void
Change the "run_processes_parallel{,_tr2}()" functions to return void, instead of int. Ever sincec553c72eed
(run-command: add an asynchronous parallel child processor, 2015-12-15) they have unconditionally returned 0. To get a "real" return value out of this function the caller needs to get it via the "task_finished_fn" callback, see the example in hook.c added in96e7225b31
(hook: add 'run' subcommand, 2021-12-22). So the "result = " and "if (!result)" code added to "builtin/fetch.c"d54dea77db
(fetch: let --jobs=<n> parallelize --multiple, too, 2019-10-05) has always been redundant, we always took that "if" path. Likewise the "ret =" in "t/helper/test-run-command.c" added inbe5d88e112
(test-tool run-command: learn to run (parts of) the testsuite, 2019-10-04) wasn't used, instead we got the return value from the "if (suite.failed.nr > 0)" block seen in the context. Subsequent commits will alter this API interface, getting rid of this always-zero return value makes it easier to understand those changes. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a083f94c21
commit
7dd5762d9f
@ -1783,11 +1783,11 @@ static int pp_collect_finished(struct parallel_processes *pp)
|
||||
return result;
|
||||
}
|
||||
|
||||
int run_processes_parallel(int n,
|
||||
get_next_task_fn get_next_task,
|
||||
start_failure_fn start_failure,
|
||||
task_finished_fn task_finished,
|
||||
void *pp_cb)
|
||||
void run_processes_parallel(int n,
|
||||
get_next_task_fn get_next_task,
|
||||
start_failure_fn start_failure,
|
||||
task_finished_fn task_finished,
|
||||
void *pp_cb)
|
||||
{
|
||||
int i, code;
|
||||
int output_timeout = 100;
|
||||
@ -1834,25 +1834,20 @@ int run_processes_parallel(int n,
|
||||
}
|
||||
|
||||
pp_cleanup(&pp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
|
||||
start_failure_fn start_failure,
|
||||
task_finished_fn task_finished, void *pp_cb,
|
||||
const char *tr2_category, const char *tr2_label)
|
||||
void run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
|
||||
start_failure_fn start_failure,
|
||||
task_finished_fn task_finished, void *pp_cb,
|
||||
const char *tr2_category, const char *tr2_label)
|
||||
{
|
||||
int result;
|
||||
|
||||
trace2_region_enter_printf(tr2_category, tr2_label, NULL, "max:%d",
|
||||
((n < 1) ? online_cpus() : n));
|
||||
|
||||
result = run_processes_parallel(n, get_next_task, start_failure,
|
||||
task_finished, pp_cb);
|
||||
run_processes_parallel(n, get_next_task, start_failure,
|
||||
task_finished, pp_cb);
|
||||
|
||||
trace2_region_leave(tr2_category, tr2_label, NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int run_auto_maintenance(int quiet)
|
||||
|
Reference in New Issue
Block a user