From kde-devel Sun Jun 17 00:52:53 2001 From: Charles Samuels Date: Sun, 17 Jun 2001 00:52:53 +0000 To: kde-devel Subject: Re: Multithreaded application development X-MARC-Message: https://marc.info/?l=kde-devel&m=99274032707010 On Saturday 16 June 2001 05:25 pm, Waldo Bastian wrote: > On Saturday 16 June 2001 04:30 pm, Aurelien Gateau wrote: > > Hi ! > > > > I'm writting a KDE application which could really benefit using threads. > > I wanted to use Qt-mt, but I read that it was not possible since KDE > > currently doesn't link against Qt-mt. I would like to avoid using OS > > specific thread libraries, so I ended up using the > > "QTimer::start(0,false)" trick to get my job done in the background, but > > it's not that efficient and the GUI doesn't response very quickly. > > I would like to now what is the current politic regarding threads in KDE > > applications ? > > 1) Don't do it > 2) If you made it to this point, KDE doesn't support it right now since we > would have to link against qt-mt for that. (As you already found out) > 3) For KDE 3.0 I guess it would make sense to use qt-mt by default not > withstanding point 1). For that it would be helpfull if people started to > share their experiences with multi-threading & KDE so that we know what to > watch out for. > > This recent slashdot article about multithreading seems to be very nice. > > Rik also wrote some interesting stuff about threading. I'm sure he will > react to your msg as well :-) I'm not rik, however, I too used threads (SDL threads, actually), see kdeaddons/noatun-plugins/nexscope/ I few good rules to live by when threading: don't use one QString (or for that matter, any Qt class) across the two threads- ever, mutex or not, unless you know what it is you're doing (implicit sharing, you can work around it by using copies, most of the classes support forcing a copy). Don't make X calls across two threads. I'm using SDL in the second thread, while this probably counts as doing this, but it works reliably, so I'm not complaining :) Feel free to wrap pthread's thread and mutex library by a class. In fact, I'de highly recommend this, it makes it a lot easier. I wrapped SDL's thread stuff in a class, doing the same to pthreads would be easy. Feel free to steal my code. Threading makes a lot of stuff a lot easier, despite what some of you all have said ;) -Charles >> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<