Re: async queue?



On Tue, Dec 11, 2001 at 12:14:20PM +0100, Sebastian Wilhelmi wrote:
> 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

This would suffice nicely.

> > 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.

If more than one producer or consumer is waiting, threads on that side
of the queue will always be woken up only to fall asleep again.

As an example of this, I believe that several GThread objects in a
GThreadPool will waiting on the same conditional. (i.e. multiple
consumers) If several threads were issuing work items to the
GThreadPool, we have several producers as well.

mark

-- 
mark mielke cc/markm ncf ca/markm nortelnetworks com __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/




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