[gameprogrammer] Single producer consumer
- From: Kevin Jenkins <gameprogrammer@xxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Thu, 09 Feb 2006 09:21:39 -0800
We're having a debate at work right now as to if you can write a
thread-safe single producer consumer class without critical section
locks. I claim you can, while another programmer claims you cannot.
This is what I use:
http://www.rakkar.org/sourcecode/SingleProducerConsumer.h.txt
What I do is have two pointers - a write pointer and a read pointer.
They cannot cross each other. Each pointer is only modified by one
thread. Both threads compare these pointers using the == operator.
There are a few articles on google claiming correctly you cannot use a
single shared pointer or index where both threads modify that variable,
but none use my approach where I have two variables and each is only
updated by its own thread.
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: Single producer consumer
- From: David Olofson
- [gameprogrammer] Re: Single producer consumer
- From: brianevans
- [gameprogrammer] Re: Single producer consumer
- From: Bob Pendleton
- References:
- [gameprogrammer] How to have hills in a tiled game
- From: Alan Wolfe
Other related posts:
- » [gameprogrammer] Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
- » [gameprogrammer] Re: Single producer consumer
--------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- [gameprogrammer] Re: Single producer consumer
- From: David Olofson
- [gameprogrammer] Re: Single producer consumer
- From: brianevans
- [gameprogrammer] Re: Single producer consumer
- From: Bob Pendleton
- [gameprogrammer] How to have hills in a tiled game
- From: Alan Wolfe