Re: async queue?



Hi Mark,

> What of modifications such as the following?
> 
> 1) The Async Queue code does not appear to deal with the traditional
>    producer/consumer problem where the producer is able to produce
>    (queue) items faster than the consumer can consume (dequeue) items.
> 
>    The result is that a lot of memory gets chewed up, when perhaps
>    a maximum queue size should block the producer until the consumer
>    has consumed a few of the items. The consumer will certainly have
>    trouble consuming if the producer is hogging a significant portion
>    of the CPU, and loading up memory in the process. This can be
>    implemented as a single value that push() will block on, or a single
>    value that push() will block on, until the queue is reduced to a
>    certain size (high and low water mark).

Indeed, that sound like a nice addition. Alas, now it's too late for
GLib 2.0. I'll add a wishlist bug for 2.2

I order not to change the API I would add

g_async_queue_new_with_max_length
g_async_queue_try_push
g_async_queue_timed_push
g_async_queue_get_max_length
g_async_queue_set_max_length

> 2) The Async Queue code should actually use two conditionials instead
>    of one after implementing the above code. One conditional is used
>    to wake up threads that are waiting to pop, while the other conditional
>    is used to wake up threads that are waiting to push.

I think, one cond var still suffices, as at a given time only one side
(either consumer or producer) can be waiting.

Bye,
Sebastian
-- 
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi





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