Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Alexander Terekhov Newsgroups: comp.programming.threads Subject: Re: usage of vyukov's mpsc queue Date: Wed, 21 Sep 2011 17:06:34 +0200 Organization: A noiseless patient Spider Lines: 26 Message-ID: <4E79FD7A.F4557F50@web.de> References: <3b312755-24d8-4505-8cfe-1644c458c4d5@j1g2000yqn.googlegroups.com> <4E79BA45.B3622870@web.de> <2011092106580817537-ephisinowitz@yahoocom> <4E79D246.E338E050@web.de> <39ca082e-34ad-43f5-8f6d-9944ae840875@l4g2000vbv.googlegroups.com> <4E79E431.59EFC897@web.de> <7f52d142-c0f4-4898-a498-2cf78fb4f97e@k15g2000yqd.googlegroups.com> Reply-To: terekhov@web.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="MCbSEzW5qwGLFMNXJh39IQ"; logging-data="23769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iFoqKJUyUfoZyQiGXwEIpqgk8UDERvoY=" X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en Cancel-Lock: sha1:mGjAM6YoM9dCEhPl6Y1PXsPu7fc= Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:590 Ephi Sinowitz wrote: [...] > Producers set event after the push(). Event only transitions from > unset to set when producer is inside the while loop. > Now when Consumer goes back to Wait he should see the set event. The > only issue is that he may still see a NULL next pointer because there > are no memory barriers in the push(). In that case the consumer will > go back to wait and the event will stay unset forever. But the 30 > second time limit should take care of that. > for(;;) > WaitForSingleObject(m_queueEvent, 30000); > while (void* item = vyukov_queue.pop()) > { > // do work > } > } With *timed* wait on in consumer, push() and pop() need the same barriers as without blocking synchronization object. Think of it as sleep(30) instead of WaitForSingleObject(m_queueEvent, 30000). regards, alexander.