From: Andrew on
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.

There is a class that would serve in ACE but ACE is huge so I do not
want to introduce ACE to the project. The project is already using
boost and fighting the battle for more boost usage is hard enough.

Does anyone know if such a facility is planned for the upcoming std?

Regards,

Andrew Marlow

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

From: Mathias Gaunard on
On 9 d�c, 02:19, Andrew <marlow.and...(a)googlemail.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.

There is one in the boost review queue.
Alternatively, there is one in Intel TBB as well.


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

From: Robert Kindred on

"Andrew" <marlow.andrew(a)googlemail.com> wrote in message
news:d5cc1f55-9de9-4f77-84d1-4d22c40d7a33(a)u7g2000yqm.googlegroups.com...
>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.
>
> There is a class that would serve in ACE but ACE is huge so I do not
> want to introduce ACE to the project. The project is already using
> boost and fighting the battle for more boost usage is hard enough.
>
> Does anyone know if such a facility is planned for the upcoming std?

The design of the ACE message queue is given in "Pattern-Oriented Software
Architecture" Volume 2 by Schmidt et. al. It is not too hard to code into
your program, provided you have access to a pthreads library.

hth,

Robert Kindred

>
> Regards,
>
> Andrew Marlow



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

From: Anthony Williams on
Andrew <marlow.andrew(a)googlemail.com> writes:

> 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.
>
> Does anyone know if such a facility is planned for the upcoming std?

No, this is not planned for C++0x. There is an example implementation of
a queue that uses boost on my blog:

http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html

Anthony
--
Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/
just::thread C++0x thread library http://www.stdthread.co.uk
Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

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

From: mzdude on
On Dec 8, 9:19 pm, Andrew <marlow.and...(a)googlemail.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.
>
> There is a class that would serve in ACE but ACE is huge so I do not
> want to introduce ACE to the project. The project is already using
> boost and fighting the battle for more boost usage is hard enough.
>
> Does anyone know if such a facility is planned for the upcoming std?
>
> Regards,
>
> Andrew Marlow
>

Check out the Intel Threaded Building Blocks. They have
concurrent_hash_map
concurrent_queue
concurrent_vector

We use the concurrent_queue for the producer/consumer. It works well.


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