Re: async queue?



Hi Mark,

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

If you mean, that upon arrival of a new item all waiting threads are
woken, you are wrong. With g_cond_signal only one will be woken.
 
> 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.

Yes, but at a given time there can either be waiting threads _or_ queued
data for threads, not both at the same time (of course, if you lock an
async queue, there can be both waiting threads and waiting data, but
that unfolds quite happily, once you unlock the queue again).

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]