Re: C++ and threading howto for linux dev
On Tue, Aug 11, 2009 at 02:47:51PM -0500, "Boyd Stephen Smith Jr." was heard to say: > Since GLib, Qt Core, LibBoost, and "C++1x" all provide C++ > bindings/abstractions of the threads, I would not write your own. I can't > recommend for or against Boost, but one of those 4 should fit your project. Boost is an excellent collection of C++ utility code, from simple stuff like type traits classes and threading wrappers, up to complex libraries like the multi-index container library or the meta-programming library. I would recommend it highly for any C++ programming. Daniel (who has written a C++ threading wrapper, but wouldn't these days) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
In , Emanoil Kotsev wrote: >Boyd Stephen Smith Jr. wrote: >> In <2009082355.2e38a...@vivalunalitshi.luna.local>, Micha Feigin >> wrote: >>>c is a subset of c++ so you can use the c api inside c++. >> >> Not entirely true. >> >> There is a common subset of C and C++ and it includes the majority of >> the C language and standard library, but do not mistake C as "C++ >> without classes". > >It needs a wrapper but things with threads (actually concurrency) are more >complicated, so I think libboost would be for me the way to go. It looks >handy. > >I'm not sure how much advantage and disadvantage is to write the code or >parts of it in C and the rest in c++. Not even sure if it's possible >without any cavities, but it fun to learn. It's certainly possible, but it requires to to you what a POD is, and when/how to use extern "C" and a few other things that a lot of C++ programmers do not need to worry about. Since GLib, Qt Core, LibBoost, and "C++1x" all provide C++ bindings/abstractions of the threads, I would not write your own. I can't recommend for or against Boost, but one of those 4 should fit your project. -- Boyd Stephen Smith Jr. ,= ,-_-. =. b...@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/\_/ signature.asc Description: This is a digitally signed message part.
Re: C++ and threading howto for linux dev
Boyd Stephen Smith Jr. wrote: > In <2009082355.2e38a...@vivalunalitshi.luna.local>, Micha Feigin > wrote: >>c is a subset of c++ so you can use the c api inside c++. > > Not entirely true. ISO 9899:1999 (C Programming Language) has a number of > types that are not in ISO 14882:2003 (C++ Programming Language), at least. > Also, the upcoming "C++1x" standard will not include the variable-length > arrays feature from "C99". There are certain valid C constructs that will > cause errors in C++, not limited to using C++ keywords as C identifiers or > using the sequence "//*" in code. > > There is a common subset of C and C++ and it includes the majority of the > C language and standard library, but do not mistake C as "C++ without > classes". Thanks Boyd, I'm not that familiar with C or C++ specifications, but that's exactly what's happening when trying to use pthreads directly from c++ and I understand completely well why. It needs a wrapper but things with threads (actually concurrency) are more complicated, so I think libboost would be for me the way to go. It looks handy. I'm not sure how much advantage and disadvantage is to write the code or parts of it in C and the rest in c++. Not even sure if it's possible without any cavities, but it fun to learn. regards -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
Micha Feigin wrote: > On Mon, 10 Aug 2009 15:09:40 -0500 > "Boyd Stephen Smith Jr." wrote: > > 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. > Ok thanks for the hint. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
In <2009082355.2e38a...@vivalunalitshi.luna.local>, Micha Feigin wrote: >c is a subset of c++ so you can use the c api inside c++. Not entirely true. ISO 9899:1999 (C Programming Language) has a number of types that are not in ISO 14882:2003 (C++ Programming Language), at least. Also, the upcoming "C++1x" standard will not include the variable-length arrays feature from "C99". There are certain valid C constructs that will cause errors in C++, not limited to using C++ keywords as C identifiers or using the sequence "//*" in code. There is a common subset of C and C++ and it includes the majority of the C language and standard library, but do not mistake C as "C++ without classes". -- Boyd Stephen Smith Jr. ,= ,-_-. =. b...@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/\_/ signature.asc Description: This is a digitally signed message part.
Re: C++ and threading howto for linux dev
On Tue, 11 Aug 2009 01:55:00 +0200 Emanoil Kotsev wrote: > ga wrote: > > > > > Check out these ones: > > > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/thread_2thread_8cc-example.html#_a11 > > > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/thread_2dispatcher_8cc-example.html#_a0 > > > > Doc: > > > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1Thread.html > > > > Thanks a lot ga. So you mean using the Glib classes. I had a look ... I can > include it in my testing list :-) > > It also links to pthread > > bash$> ldd /usr/lib/libgtkmm-2.4.so.1.0.30 > linux-gate.so.1 => (0xb8007000) > libgdkmm-2.4.so.1 => /usr/lib/libgdkmm-2.4.so.1 (0xb7c65000) > > libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 > > I bet qt is also using pthread > > So it's better to access pthread myself. The advantage of using the above > and not pthread is that everything has been packed in a class already. > > The above examples are still very useful to give an idea of the > implementation logic. > > Thanks and kind regards > > > As far as I know all linux thread implementation link to ptreahds. Everything else is a wrapper around pthreads. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
On Mon, 10 Aug 2009 15:09:40 -0500 "Boyd Stephen Smith Jr." wrote: > In , 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. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
On Mon, 10 Aug 2009 19:09:05 +0200 Emanoil Kotsev wrote: > Hi, perhaps it's OT but still the debian list is the best one (my subjective > opinion), so I dear to ask here. > > 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. > > Does any one know a good howto (working one - tested hin/herself) > > I tried a bunch of junk over the weekend and could make it > > 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? > > Thanks in advance > > c is a subset of c++ so you can use the c api inside c++. Another option is to use a wrapper library. If you want cross platform c++ and you are not using a specific gui library (qt or gtk) then: boost thread is one option (package libboost-thread1.38-dev in unstable) I also worked with wxwidgets which is a cross platform gui library that includes some extra stuff qt probably also has something, don't know if gtk covers such stuff. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
ga wrote: > > Check out these ones: > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/thread_2thread_8cc-example.html#_a11 > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/thread_2dispatcher_8cc-example.html#_a0 > > Doc: > http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1Thread.html > Thanks a lot ga. So you mean using the Glib classes. I had a look ... I can include it in my testing list :-) It also links to pthread bash$> ldd /usr/lib/libgtkmm-2.4.so.1.0.30 linux-gate.so.1 => (0xb8007000) libgdkmm-2.4.so.1 => /usr/lib/libgdkmm-2.4.so.1 (0xb7c65000) libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 I bet qt is also using pthread So it's better to access pthread myself. The advantage of using the above and not pthread is that everything has been packed in a class already. The above examples are still very useful to give an idea of the implementation logic. Thanks and kind regards -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
Eric Meijer wrote: > Emanoil Kotsev wrote: >> Thanks Eric >> >> I was also thinking to use the boost package. I don't like it's heavy and >> my app would depend on it too. >> >> > As mentioned by Roger Leigh, you only really "pay" for what you are using. > Why are you worried by the dependence on boost? > What I like about it is that boost really is the place where new > libraries for upcoming C++ standards are developed are tested. As a > result boost is really widely used, well regarded in the C++ community, > and consequently high quality. It is also likely that C++ threads will > look a lot like the boost implementation when they arrive in the standard. >> So there is no easy way around pthreads from C++ except boost? >> > As suggested by Roger, you could use the pthreads directly. I prefer > the C++ interface from boost. > > Agreed. I'm just not that familiar to C++. I like objects and I'm wondering how threads are implemented that's all. :-) I didn't expect it being this way honestly. I understand one good approach would be libboost. Thanks for that and kind regards -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
Emanoil Kotsev wrote: Thanks Eric I was also thinking to use the boost package. I don't like it's heavy and my app would depend on it too. As mentioned by Roger Leigh, you only really "pay" for what you are using. Why are you worried by the dependence on boost? What I like about it is that boost really is the place where new libraries for upcoming C++ standards are developed are tested. As a result boost is really widely used, well regarded in the C++ community, and consequently high quality. It is also likely that C++ threads will look a lot like the boost implementation when they arrive in the standard. So there is no easy way around pthreads from C++ except boost? As suggested by Roger, you could use the pthreads directly. I prefer the C++ interface from boost. Regards, Eric -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
On Mon, Aug 10, 2009 at 07:09:05PM +0200, Emanoil Kotsev wrote: > 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? Just use pthreads directly. Boost threads is also an option I would suggest. Your comment about Boost being big is true, but you only pay for the bits you use (in this case the thread headers and linking against libboost_thread-mt). Just install libboost-thread-dev. Regards, Roger -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `-GPG Public Key: 0x25BFB848 Please GPG sign your mail. signature.asc Description: Digital signature
Re: C++ and threading howto for linux dev
Hi Emanoil, On Mon, Aug 10, 2009 at 07:09:05PM +0200, Emanoil Kotsev wrote: > Hi, perhaps it's OT but still the debian list is the best one (my subjective > opinion), so I dear to ask here. > > 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. > > Does any one know a good howto (working one - tested hin/herself) Check out these ones: http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/thread_2thread_8cc-example.html#_a11 http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/thread_2dispatcher_8cc-example.html#_a0 Doc: http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1Thread.html Regards, . > > I tried a bunch of junk over the weekend and could make it > > 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? > > Thanks in advance > > > -- > To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org > with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org > -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
In , 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. >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. -- Boyd Stephen Smith Jr. ,= ,-_-. =. b...@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/\_/ signature.asc Description: This is a digitally signed message part.
Re: C++ and threading howto for linux dev
Eric Meijer wrote: >> > Boost threads is what I use (debian package libboost-thread-dev). It > builds on pthreads, and is part of the high quality boost library for > C++, which is a kind of testbed for libraries to be added to the C++ > standard library. You may want to browse boost for more useful stuf. >> I tried a bunch of junk over the weekend and could make it >> >> 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? >> >> > Multi-threaded development is always hard and needs at least some extra > care. See also the docs in libboost-doc. > > Regards, > Eric Thanks Eric I was also thinking to use the boost package. I don't like it's heavy and my app would depend on it too. So there is no easy way around pthreads from C++ except boost? Any alternatives? thanks in advance -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
Hugo Vanwoerkom wrote: > I use QT and their examples: they are the greatest! > http://packages.debian.org/sid/qt4-doc-html > > Hugo Hi, I'm not looking for a graphics implementation of threads but a way to run threads from pure C++ code. What should I do with QT? I make my app depending on something I don't really need. I actually found a howto but without working examples (means I have to implement and try it) and I'm refusing to believe nobody did it before. The few other howtos were not working for me I either need to spend another weekend or somebody could give me a good example. I actually found this implementation http://code.google.com/p/cppthreadpool/ coming very close to the theoretical one I found. ... and tried it but it's waiting for the server to exit to fetch the next function ... either I didn't implement it the right way or it's a pseudo threading. I'm investigating now. Is there an expert to have a look at the code? and what about the clone() function I read is available in linux? regards -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
Emanoil Kotsev wrote: Hi, perhaps it's OT but still the debian list is the best one (my subjective opinion), so I dear to ask here. 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. Does any one know a good howto (working one - tested hin/herself) Boost threads is what I use (debian package libboost-thread-dev). It builds on pthreads, and is part of the high quality boost library for C++, which is a kind of testbed for libraries to be added to the C++ standard library. You may want to browse boost for more useful stuf. I tried a bunch of junk over the weekend and could make it 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? Multi-threaded development is always hard and needs at least some extra care. See also the docs in libboost-doc. Regards, Eric -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: C++ and threading howto for linux dev
Emanoil Kotsev wrote: Hi, perhaps it's OT but still the debian list is the best one (my subjective opinion), so I dear to ask here. 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. Does any one know a good howto (working one - tested hin/herself) I tried a bunch of junk over the weekend and could make it 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? I use QT and their examples: they are the greatest! http://packages.debian.org/sid/qt4-doc-html Hugo -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org