[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C++ and threading howto for linux dev



On Mon, 10 Aug 2009 15:09:40 -0500
"Boyd Stephen Smith Jr." <bss@iguanasuicide.net> wrote:

> In <[🔎] h5pk7i$bns$7@ger.gmane.org>, Emanoil Kotsev wrote:
> >I'm willing to build an app that starts 3 threads, especially (soap
> > client, server from libcsoap and terminal), so I couldn't manage to do
> > the job in C++, because they it lacks native threading support. PThread
> > lib is C.
> 
> I've always been able to use the pthread library from C++ as well.  You do 
> need to make sure that your thread functions are callable from C, but that 
> it rarely a problem.
> 

One way to do it by the way if you want them encapsulated inside a class is to
use static member functions (they are actually just standard function with a
limited scope). Then you don't need to define them as friend, you do need to
pass a pointer to the relevant class though.

> >I also couldn't find a user-list for libcsoap, but the question is a
> > general one - HOW THE H**L ARE YOU WRITING threaded apps in C++. It
> > shouldn't be that hard - or is it?
> 
> 1. POSIX/SUSv2 pthreads is a absolutely has to work with minimal 
> dependencies on multiple UNIX-alike platforms.
> 
> 2. Qt4 Threads for most things.  Qt4 Threads are arguably more portable than 
> pthreads, and with modular Qt4, you don't have to pull in X11 libraries if 
> you don't need them.
> 
> 3. I hear boost has a threading library.  I've never used boost for 
> anything, but if I couldn't use Qt4 or pthreads, I'd consider it.
> 
> 4. C++1x should have native thread primitives and should be fairly close to 
> complete.  Depending on how good your libstdc++/gcc support the soon-to-be 
> standard interface you could write to this.


Reply to: