From: Andrew on
On 30 Dec, 05:43, yeroen <gmrehb...(a)gmail.com> wrote:
> > I am designing a system where an app will need to spawn a child thread
> > then the child and parent thread will need to communicate. If this was
> > in java I would use ConcurrentLinkedQueue but what to do in C++? I
> > have googled and searched boost but cannot find anything.
>
> Herb Sutter, building on earlier work of Petru Marginean,
> authored a series of articles in Dr. Dobbs containing a complete C++
> implementation of a lock-free
> concurrent queue:

> The implementation depends on the availability of the std::atomic<>
> template, which may or may not be provided by
> your current working compiler.

Thanks for the pointer but I really need a portable solution. The
compiler I am using is Visual Studio 2005. I have found that the code
provided by Anthony Williams works great. It uses boost which takes
care of the portability issues.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Chris M. Thomasson on
"Chris M. Thomasson" <no(a)spam.invalid> wrote in message
news:vKA_m.44056$_b5.11875(a)newsfe22.iad...
[...]

> Okay. As for STL deque, I personally prefer intrusive data-structures.
> Here
> is sketch for a queue:
>
> <pseudo-code in news reader>
> ___________________________________________________________
> struct node
> {
> node* m_next;
> };
>
>
> struct queue
> {
> node* m_head; // = NULL
> node* m_tail;
>
>
> void push(node* n)
> {


// DAMN IT !

// I forgot to set the next pointer of the new node to NULL!



n->m_next = NULL;



// Sorry about that non-sense!

// ;^(...



> if (! m_head)
> {
> m_head = n;
> }
>
> else
> {
> m_tail->m_next = n;
> }
>
> m_tail = n;
> }
>
>
> node* pop()
> {
[...]
> }
> };
> ___________________________________________________________


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]