[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: threads
From:       Waldo Bastian <bastian () suse ! de>
Date:       1999-12-05 14:10:42
[Download RAW message or body]

On Sat, 04 Dec 1999, Jo Dillon wrote:

> Perhaps some or all of this code could be useful in KDE if people want
> to use threads?

For KDE 2.x / 3.0 it would be nice if we could have a generic thread support 
that allows us to do Load/Save and computational expensive operations easily 
without blocking the GUI. 

Such a thread meachnism should be cooperative, non-blocking and most important 
optional.

I am confident that a class like KThread is pretty much the way to go but at 
the moment there are too many problems with it.

One of the problems which should be addressed in Qt is how to pass classes 
which contain shared data from the main thread to a worker thread. I think that 
this requires the re-intorduction of a "detach" function in such classes.

Example: A worker-thread that reads in an image file. Reading in an image file 
can take a considerable amount of time depending on the image size and is very 
hard to split up. Basically the worker thread needs to do:

my_worker_thread(QString filename)
{
  filename.detach();
  unlock_Mutex();
  QImage image = new QImage(filename);
  lock_Mutex();
}

Without the detach() the filename QString could cause problems.

Apart from this, the QImage class should be thread safe with respect to global 
variables.

Cheers,
Waldo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic