Skip to content

Commit 36d69bf

Browse files
avargitster
authored andcommitted
run-command API: move *_tr2() users to "run_processes_parallel()"
Have the users of the "run_processes_parallel_tr2()" function use "run_processes_parallel()" instead. In preceding commits the latter was refactored to take a "struct run_process_parallel_opts" argument, since the only reason for "run_processes_parallel_tr2()" to exist was to take arguments that are now a part of that struct we can do away with it. See ee4512e (trace2: create new combined trace facility, 2019-02-22) for the addition of the "*_tr2()" variant of the function, it was used by every caller except "t/helper/test-run-command.c".. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6e5ba0b commit 36d69bf

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

builtin/fetch.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,15 +1953,21 @@ static int fetch_multiple(struct string_list *list, int max_children)
19531953

19541954
if (max_children != 1 && list->nr != 1) {
19551955
struct parallel_fetch_state state = { argv.v, list, 0, 0 };
1956+
const struct run_process_parallel_opts opts = {
1957+
.tr2_category = "fetch",
1958+
.tr2_label = "parallel/fetch",
1959+
1960+
.processes = max_children,
1961+
1962+
.get_next_task = &fetch_next_remote,
1963+
.start_failure = &fetch_failed_to_start,
1964+
.task_finished = &fetch_finished,
1965+
.data = &state,
1966+
};
19561967

19571968
strvec_push(&argv, "--end-of-options");
1958-
run_processes_parallel_tr2(max_children,
1959-
&fetch_next_remote,
1960-
&fetch_failed_to_start,
1961-
&fetch_finished,
1962-
&state,
1963-
"fetch", "parallel/fetch");
19641969

1970+
run_processes_parallel(&opts);
19651971
result = state.result;
19661972
} else
19671973
for (i = 0; i < list->nr; i++) {

builtin/submodule--helper.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,12 +2567,20 @@ static int update_submodules(struct update_data *update_data)
25672567
{
25682568
int i, ret = 0;
25692569
struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;
2570+
const struct run_process_parallel_opts opts = {
2571+
.tr2_category = "submodule",
2572+
.tr2_label = "parallel/update",
2573+
2574+
.processes = update_data->max_jobs,
2575+
2576+
.get_next_task = update_clone_get_next_task,
2577+
.start_failure = update_clone_start_failure,
2578+
.task_finished = update_clone_task_finished,
2579+
.data = &suc,
2580+
};
25702581

25712582
suc.update_data = update_data;
2572-
run_processes_parallel_tr2(suc.update_data->max_jobs, update_clone_get_next_task,
2573-
update_clone_start_failure,
2574-
update_clone_task_finished, &suc, "submodule",
2575-
"parallel/update");
2583+
run_processes_parallel(&opts);
25762584

25772585
/*
25782586
* We saved the output and put it out all at once now.

run-command.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,24 +1827,6 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
18271827
trace2_region_leave(tr2_category, tr2_label, NULL);
18281828
}
18291829

1830-
void run_processes_parallel_tr2(size_t processes, get_next_task_fn get_next_task,
1831-
start_failure_fn start_failure,
1832-
task_finished_fn task_finished, void *pp_cb,
1833-
const char *tr2_category, const char *tr2_label)
1834-
{
1835-
const struct run_process_parallel_opts opts = {
1836-
.tr2_category = tr2_category,
1837-
.tr2_label = tr2_label,
1838-
.processes = processes,
1839-
1840-
.get_next_task = get_next_task,
1841-
.start_failure = start_failure,
1842-
.task_finished = task_finished,
1843-
};
1844-
1845-
run_processes_parallel(&opts);
1846-
}
1847-
18481830
int run_auto_maintenance(int quiet)
18491831
{
18501832
int enabled;

run-command.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,6 @@ struct run_process_parallel_opts
528528
* conditions due to writing in parallel to stdout and stderr.
529529
*/
530530
void run_processes_parallel(const struct run_process_parallel_opts *opts);
531-
void run_processes_parallel_tr2(size_t processes, get_next_task_fn,
532-
start_failure_fn, task_finished_fn, void *pp_cb,
533-
const char *tr2_category, const char *tr2_label);
534531

535532
/**
536533
* Convenience function which prepares env for a command to be run in a

submodule.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,17 @@ int fetch_submodules(struct repository *r,
18191819
{
18201820
int i;
18211821
struct submodule_parallel_fetch spf = SPF_INIT;
1822+
const struct run_process_parallel_opts opts = {
1823+
.tr2_category = "submodule",
1824+
.tr2_label = "parallel/fetch",
1825+
1826+
.processes = max_parallel_jobs,
1827+
1828+
.get_next_task = get_next_submodule,
1829+
.start_failure = fetch_start_failure,
1830+
.task_finished = fetch_finish,
1831+
.data = &spf,
1832+
};
18221833

18231834
spf.r = r;
18241835
spf.command_line_option = command_line_option;
@@ -1840,12 +1851,7 @@ int fetch_submodules(struct repository *r,
18401851

18411852
calculate_changed_submodule_paths(r, &spf.changed_submodule_names);
18421853
string_list_sort(&spf.changed_submodule_names);
1843-
run_processes_parallel_tr2(max_parallel_jobs,
1844-
get_next_submodule,
1845-
fetch_start_failure,
1846-
fetch_finish,
1847-
&spf,
1848-
"submodule", "parallel/fetch");
1854+
run_processes_parallel(&opts);
18491855

18501856
if (spf.submodules_with_errors.len > 0)
18511857
fprintf(stderr, _("Errors during submodule fetch:\n%s"),

0 commit comments

Comments
 (0)