git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: Palmer Dabbelt <palmer@sifive.com>
Cc: git@vger.kernel.org, peff@peff.net, chriscool@tuxfamily.org,
	gitster@pobox.com, jonathantanmy@google.com, tboegi@web.de,
	bwilliams.eng@gmail.com, jeffhost@microsoft.com
Subject: Re: [PATCH v2 2/5] fetch: Add the "--fetch-jobs" option
Date: Tue, 13 Aug 2019 14:44:41 +0000	[thread overview]
Message-ID: <20190813144441.qw5i3zbrvebz5o7z@dcvr> (raw)
In-Reply-To: <20190812213448.2649-3-palmer@sifive.com>

Palmer Dabbelt <palmer@sifive.com> wrote:
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 8aa6a0caf1ab..fa12ad44e7d9 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c

<snip>

> +static int next_remote_to_fetch(struct child_process *cp,
> +				struct strbuf *out,
> +				void *state_uncast,
> +				void **task_state_out)
> +{
> +	int i;
> +	struct fetch_remote *state = state_uncast;
> +	struct fetch_remote_task *task_state = NULL;
> +	const char *remote_name;
> +
> +	if (state->next_remote_index >= state->all_remotes->nr)
> +		return 0;
> +
> +	remote_name = state->all_remotes->items[state->next_remote_index].string;
> +	state->next_remote_index++;
> +
> +	/*
> +	 * Finds somewhere to store the state for a task.  This is guarnteed to
> +	 * succeed because there are always enough tasks allocated to cover the
> +	 * number that have been requested to run in parallel.  Rather than
> +	 * bothering with some sort of free list, this just brute force
> +	 * searches for a free task.  The assumption is that there aren't that
> +	 * many tasks to look through.
> +	 */
> +	for (i = 0; i < state->task_count; ++i) {
> +		if (!state->all_tasks[i].in_use) {
> +			task_state = state->all_tasks + i;
> +			break;
> +		}
> +	}

Fwiw, I added list.h, the linked-list derived from the Linux
kernel to simplify usage of free lists, queues, etc...

I think it could improve readability, too; but I'm not really
a C programmer and prefer high-level scripting languages.

  reply	other threads:[~2019-08-13 14:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-12 21:34 [PATCH v2 0/5] fetch: Extend --jobs to multiple remotes Palmer Dabbelt
2019-08-12 21:34 ` [PATCH v2 1/5] fetch: Rename max_children to max_children_for_submodules Palmer Dabbelt
2019-08-12 21:34 ` [PATCH v2 2/5] fetch: Add the "--fetch-jobs" option Palmer Dabbelt
2019-08-13 14:44   ` Eric Wong [this message]
2019-08-12 21:34 ` [PATCH v2 3/5] fetch: Add the fetch.jobs config key Palmer Dabbelt
2019-08-12 21:34 ` [PATCH v2 4/5] fetch: Add the --submodule-fetch-jobs option Palmer Dabbelt
2019-08-12 21:34 ` [PATCH v2 5/5] fetch: Make --jobs control submodules and remotes Palmer Dabbelt
2019-08-13 20:16   ` Johannes Schindelin
2019-08-13 22:06     ` Palmer Dabbelt
2019-08-13 22:00   ` Junio C Hamano
2019-08-13 22:06     ` Palmer Dabbelt
2019-08-14  8:32   ` SZEDER Gábor
2019-08-14 15:54     ` Junio C Hamano
2019-08-14 18:33     ` Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190813144441.qw5i3zbrvebz5o7z@dcvr \
    --to=e@80x24.org \
    --cc=bwilliams.eng@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --cc=jonathantanmy@google.com \
    --cc=palmer@sifive.com \
    --cc=peff@peff.net \
    --cc=tboegi@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).