Big Qthread vs. pthread and usleep problem

Anno v. Heimburg anno at vonheimburg.de
Fri Nov 30 00:09:19 GMT 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Freitag 30 November 2001 00:13 schrieb Ivica Bukvic:
> 1) I tried changing over to Qthreads, but the problem is whenever I
> declare a new clas:
>
> class foo : public QThread
>
> this yields syntax error due to QThread (if it is any other qt class,
> this line reports no syntax error. What is wrong wit this? I am using

- From the QThread doc:
"On Unix, thread support is enabled by adding the -thread option when running 
the configure script. On Unix platforms where multithreaded programs must be 
linked in special ways, such as with a special libc, installation will create 
a separate library, libqt-mt and hence threaded programs must be linked 
against this library (with -lqt-mt) rather than the regular Qt library. 

On both platforms, you should compile with the macro QT_THREAD_SUPPORT 
defined (eg. compiler with -DQT_THREAD_SUPPORT). On Windows, this is usually 
done by an entry in qconfig.h. "

So I guess you should check wether you have a lqt-mt lib, and link that, too, 
if there is one. I don't know if you meant this by --enable-mt,perhaps it was 
the right idea but the worng configure switch.


>
> 2) I am using pthread_create right now (everything works), but since the
> loop within the thread is infinite, it poses as a serious resource hog.
> So, what I decided to do is to add usleep(10000) value which would give
> me 10ms sleep "sessions" in between the counting, since my timer only
> uses two decimal points for subdivisions of the second. But whenever I
> do this and compile the program, the application's timer runs SLOWER, no
> matter what is the usleep value (even if it is 1!), and only speeds up
> to what it is supposed to be when I move/wiggle the mouse over the main
> app's widget, and/or click with the mouse. Why the heck is this

I have know idea why this is happenening, as you say it seems to be linked 
with the qt/pthread-usleep combination.  Shot in the wild: Have you tried to 
use a QTimer in the thread which emits a timeout signal every 10 ms, and 
connected the counting function with that timer? This shouldn't work, 
actually, since if the thread is slowed down, the QTimer would be slowed 
down, too. On the other hand, the speed which whith the main app is running 
should have nothing to do with the thread's speed, so I'ld give it a try.


> I would greatly appreciate any help I can get on this issue. Thank you!
> Sincerely,
>
> Ivica Bukvic
>
>
>
>
> -
> to unsubscribe from this list send an email to
> kdevelop-request at kdevelop.org with the following body: unsubscribe
> »your-email-address«

- -- 
http://www.vonheimburg.de
PGP public key: http://www.vonheimburg.de/anno.asc
ICQ #106858752
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8Bs4zR08QcebZvh8RAkBuAJwIpxZPyR4zltv5b86agQ2XonAhIwCfTHAO
2spQde8KW8m4zQYocG+a1/c=
=8kLa
-----END PGP SIGNATURE-----

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list