Re: [PATCH v1 1/3] add unbounded Multi-Producer-Multi-Consumer queue
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 19, 2018, 19:11 UTC
- Message-ID
- <xmqqsh4fdos4.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180718204458.20936-2-benpeart@microsoft.com>
Ben Peart <Ben.Peart@microsoft.com> writes:
Show 18 quoted lines
> +/*
> + * struct mpmcq_entry is an opaque structure representing an entry in the
> + * queue.
> + */
> +struct mpmcq_entry {
> + struct mpmcq_entry *next;
> +};
> +
> +/*
> + * struct mpmcq is the concurrent queue structure. Members should not be
> + * modified directly.
> + */
> +struct mpmcq {
> + struct mpmcq_entry *head;
> + pthread_mutex_t mutex;
> + pthread_cond_t condition;
> + int cancel;
> +};This calls itself a queue, but a new element goes to the beginning of a singly linked list, and the only way to take an element out is from near the beinning of the linked list, so it looks more like a LIFO stack to me.
I do not know how much it matters, as the name mpmcq is totally opaque to readers so perhaps readers are not even aware of various aspects of the service, e.g. how it works, what fairness it gives to the calling code, etc.