[Kde-perl] QThread anyone?

Ashley Winters jahqueel at yahoo.com
Sun May 11 14:08:30 CEST 2003


--- Germain Garand <germain at ebooksfrance.org> wrote:
> Le Lundi 05 Mai 2003 05:54, Ringwraith a écrit :
> > Hey guys... I have a "dumb" question, but I am learning.. Is there
> > anyway I can use QThread? when i call a new instance of it it says
> no
> > method call for Qt::Thread. And if there is a way would i have to
> have a
> > perl interpreter with threads support?
> >
> 
> Hi,
> The only practical way you could use threads with PerlQt would be
> through 
> ithreads (so, yes, you'd need to have those built in your
> interpreter, as 
> well as a thread-enabled Qt) and passing messages (e.g
> Qt::CustomEvents )to 
> Qt::Application::postEvent
> 
> That's not possible now though, since PerlQt isn't thread safe at
> all.
> I'll dig into that for the next release, it looks interesting. 

Ugh. Yes, PerlQt is not thread-safe. In order to acheive thread-safety,
we can't keep any Perl SV* type variables in a global C variable.

When a Perl thread is spawned, it clones all the variables into
separate interpreters, and performs draconian global interpreter
locking upon accessing anything shared between threads. Therefore, any
Perl variables PerlQt uses would have to be stored within the Perl
interpreter, and retrieved from Perl-space when used.

The better answer is: use Qt thread-safe datastructures everywhere!
Yay!

Does a QThread have to be created before the Qt datastructures start
locking themselves?

Ashley Winters

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com


More information about the Kde-perl mailing list