Re: [PATCH 2/5] thread-utils: add a threaded task queue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Stefan,

On 2015-08-27 02:52, Stefan Beller wrote:

> diff --git a/run-command.c b/run-command.c
> index 28e1d55..cb15cd9 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -668,6 +668,22 @@ int git_atexit(void (*handler)(void))
>  
>  #endif
>  
> +void setup_main_thread(void)
> [...]
>
> diff --git a/thread-utils.c b/thread-utils.c
> index a2135e0..b45ab92 100644
> --- a/thread-utils.c
> +++ b/thread-utils.c
> [...]
> +/* FIXME: deduplicate this code with run-command.c */
> +static void setup_main_thread(void)

Do you remember off-hand why the code could not be moved to thread-utils.c wholesale? Just curious.

> +#else /* NO_PTHREADS */
> +
> +struct task_queue {
> +	int early_return;
> +};
> +
> +struct task_queue *create_task_queue(unsigned max_threads)
> +{
> +	struct task_queue *tq = xmalloc(sizeof(*tq));
> +
> +	tq->early_return = 0;
> +}
> +
> +void add_task(struct task_queue *tq,
> +	      int (*fct)(struct task_queue *tq, void *task),

Might make sense to typedef this... Maybe task_t?

> +	      void *task)
> +{
> +	if (tq->early_return)
> +		return;

Ah, so "early_return" actually means "interrupted" or "canceled"?

I guess I will have to set aside some time to wrap my head around the way tasks are handled here, in particular how the two `early_return` variables (`dispatcher()`'s local variable and the field in the `task_queue`) interact.

Thanks!
Dscho
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]