C++ threads...

B

barcaroller

If this is not the right newsgroup for "C++ threads", please consider this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?
 
V

verdverm

If this is not the right newsgroup for "C++ threads", please consider this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?

I am wondering the same thing also...
I havd tried the posix threads with multiple socket clients making
high rate requests and they start hanging (always in socket::recv()
like waiting for incoming data? ), not all at the same time, and not
always all of them.

Not sure if its a thread memory problem or a problem with the TCP
handshake
The threads have access to a global static vector and make ~25 GET
http requests per minute

gcc 4.1 / kernel 2.6.20 / basically most recent stable releases

Thoughts...?
 
I

Ian Collins

barcaroller said:
If this is not the right newsgroup for "C++ threads", please consider this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?
Search this group's archive for "threads", the topic has come up fairly
often.
 
J

Jacek Dziedzic

barcaroller said:
If this is not the right newsgroup for "C++ threads", please consider this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?

There's this thing called ZThread or ZThreads, but
I have never tried it actually.

HTH,
- J.
 
M

Michael Oswald

barcaroller said:
POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?


Maybe a bit of overkill, but have a look at ACE (Adaptive Communication
Environment) library, which has rather good thread classes and managers
for thread pools an the like.


Michael
 
J

James Kanze

I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:
POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads
There must be others. Any recommendations?

I'd go with Boost. To date, I've not seen any with an interface
really like, but Boost is low enough level that it's easy to
wrap, it's probably the only one which has a good interface for
the function in the other thread, and it's pretty portable, and
looks rather robust. Of the other two I've experimented with,
Posix threads don't work under Windows, of course, and ACE is
buggy, and the idioms it uses are very out of date. When
portability between systems isn't a concern, I'll use Posix
directly. When portability to older compilers isn't a concern,
I'll use Boost. (When both portabilities are a concern, you've
got your work cut out for you:).)
 
B

Boris

If this is not the right newsgroup for "C++ threads", please consider
this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to
use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?

Depending on how much control you need over threads OpenMP might be an
option, too. It's not C++ at all but uses #pragmas. The article at
http://en.wikipedia.org/wiki/OpenMP should be enough for a quick overview.
However I think you need at least GCC 4.1 or 4.2.

Boris
 
P

P.J. Plauger

I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to
use.
The options I've found so far are:
POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads
There must be others. Any recommendations?

I'd go with Boost. To date, I've not seen any with an interface
really like, but Boost is low enough level that it's easy to
wrap, it's probably the only one which has a good interface for
the function in the other thread, and it's pretty portable, and
looks rather robust. Of the other two I've experimented with,
Posix threads don't work under Windows, of course, and ACE is
buggy, and the idioms it uses are very out of date. When
portability between systems isn't a concern, I'll use Posix
directly. When portability to older compilers isn't a concern,
I'll use Boost. (When both portabilities are a concern, you've
got your work cut out for you:).)

[pjp] The threading library we provide with our Compleat library
is Boost compatible and works atop Windows, Posix, and Linux
threads. It also has a C interface, unlike Boost threads.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 
F

Fei Liu

verdverm said:
I am wondering the same thing also...
I havd tried the posix threads with multiple socket clients making
high rate requests and they start hanging (always in socket::recv()
like waiting for incoming data? ), not all at the same time, and not
always all of them.

Not sure if its a thread memory problem or a problem with the TCP
handshake
The threads have access to a global static vector and make ~25 GET
http requests per minute

gcc 4.1 / kernel 2.6.20 / basically most recent stable releases

Thoughts...?

Most likely you have done something wrong. Apache2 can use pthread and I
never heard they had issue like you described. Read the apache2 source
code if you need inspiring examples of MT network programming.

Fei
 
M

mlimber

I'd go with Boost. To date, I've not seen any with an interface
really like, but Boost is low enough level that it's easy to
wrap, it's probably the only one which has a good interface for
the function in the other thread, and it's pretty portable, and
looks rather robust. Of the other two I've experimented with,
Posix threads don't work under Windows, of course, and ACE is
buggy, and the idioms it uses are very out of date. When
portability between systems isn't a concern, I'll use Posix
directly. When portability to older compilers isn't a concern,
I'll use Boost. (When both portabilities are a concern, you've
got your work cut out for you:).)

I've used Boost.Threads with success, too, and I'd recommend it.
Here's an article in DDJ describing how to use them:

http://www.ddj.com/dept/cpp/184401518

And here's a report on the on-going discussion of threads in the next
version of C++:

http://www.artima.com/cppsource/threads_meeting.html

See also the Creator's brief mention of threads in the context of the
next version of C++:

http://www.artima.com/cppsource/cpp0x.html

Cheers! --M
 
G

Gianni Mariani

barcaroller said:
If this is not the right newsgroup for "C++ threads", please consider this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?

I use Austria C++ ... Ok ok I wrote it too...

unreleased version is here - sourceforge has an earlier official release.
http://netcabletv.org/public_releases/
 
S

slot

If this is not the right newsgroup for "C++ threads", please consider this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?

Hello barcaroller. I havent tried the C++ threads from sourceForge,
but in my eyes you can choose either POSIX threads, if you like to get
your hands dirty, and want to know what the Boost/C++ Threads is doing
while running. This is only if you want to take a close study on the
many things that you can do with a thread. If you just want an easy
interface and dont care what is happining then choose the
Boost.Threads. It is good and safe.
I havent heard about any other implementations.
 
G

Gianni Mariani

barcaroller said:
If this is not the right newsgroup for "C++ threads", please consider this
message off-topic and ignore it.
---------------------------------------------
I am writing a multi-threaded application in C++ (on Linux) and I'm
wondering whether there are any recommendations on which C++ threads to use.
The options I've found so far are:

POSIX threads (C interface)
C++ Threads (from SourceForge)
Boost.Threads

There must be others. Any recommendations?


Oh - I forgot to mention CommonC++.
 
G

Guest

James said:
> ... and ACE is buggy, and the idioms it uses are very out of date...

I expect that ACE developers would be very grateful for any bug
report you submit. They would probably even implement any up-to-date
idiom, provided it makes sense. ACE is, after all, an actively
developed project.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,634
Latest member
RonnyBoelk

Latest Threads

Top