From: Goran Pusic on
On Dec 9, 3:19 am, 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

Most obvious candidate (for me): http://www.threadingbuildingblocks.org/

(If I am not mistaken...) Note that it's not a surprise that there's
no standard library support for anything concurrency : up to the very
latest standard, language knew zilch about threading.

Goran.


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

From: Andrew on
On 9 Dec, 22:59, "Robert Kindred" <RKind...(a)SwRI.edu> wrote:
> > 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.

I would much rather use a library than code it myself.

I do not have access to the pthreads library. The code is locked into
a Micro$oft environment so some POSIX functions are not available. I
know about the WIN32 port of pthreads which is great, I have used it
before. However, on my current project there would be strong
resistance to using this. The project does use boost so boost threads
would be the only kind of threads that would be accepted.


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

From: Andrew on
On 9 Dec, 22:56, Anthony Williams <anthony....(a)gmail.com> wrote:
> Andrew <marlow.and...(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.

What a pity. Well, at least I know now.

> There is an example implementation of
> a queue that uses boost on my blog:
>
> http://www.justsoftwaresolutions.co.uk/threading/implementing-a-threa...
>
> Anthony

Wow, this is great, just want I needed, thanks! It's all coming back
to me, thanks to your article. I did something very similar to this,
using condition variables, when I had to solve this problem on Solaris
a couple of years ago.

-Andrew Marlow

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

From: Branimir Maksimovic on
Andrew 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?

I would advise against using threads. Processes and shared memory is
much more easier to maintain, no threading problems and performance
you gain from threads does not matter because there is always
something slow like hard disk and database which will make
no difference between processes and threads.

In java using threads is slower then using processes because
it is faster to have one gc per thread then one gc per
many threads.
So in java using processes will always be faster then using
threads because of gc which kills performance of threads anyway.

Greets

--
http://maxa.homedns.org/

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

From: Francis Glassborow on
Branimir Maksimovic wrote:
> Andrew 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?
>
> I would advise against using threads. Processes and shared memory is
> much more easier to maintain, no threading problems and performance
> you gain from threads does not matter because there is always
> something slow like hard disk and database which will make
> no difference between processes and threads.
>
> In java using threads is slower then using processes because
> it is faster to have one gc per thread then one gc per
> many threads.
> So in java using processes will always be faster then using
> threads because of gc which kills performance of threads anyway.
>

All that may be perfectly true on a single core single CPU system. But
if your system provides concurrent execution and your language
implementation provides for concurrency then I do not see how your
argument works. As C++ does not have GC I do not see how that is
relevant either.

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