[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: threading in kde
From: Andrew Sutton <ansutton () sep ! com>
Date: 2001-09-18 19:51:31
[Download RAW message or body]
On Thursday 30 August 2001 02:03, Andrew Sutton wrote:
> hi all,
> <snip rest of thread>
hi again.
i was just writing to let you know that i ported all my threading work back
to qt rewroting the entire thread core. i sent the patches back to trolltech
and they expressed interest in the changes.
if anybody is interested, let me know, i'll send you the modified files,
although you'll have to integrate that into qt3 yourself (makefiles, etc.).
it only works on linux and there's no gaurantee that trolltech will use the
code. i just wanted to let you know that its done, and offers a little more
functionality then before.
and no - you won't have to rewrite applications that already use QThread
unless you use the QThread::current() method - which is recommended against.
here's what i did:
QThread changes:
- rewrote internal state management
- removed global thread list
- replace QThread::current() with a method that actually
returns the current thread object instead of handle
- rewrote QThread::exit to use a TLS representation of
the current thread (see QThread::current()).
- default registration with global, default QThreadManager
- added QThread::setManager(), QThread::getManager() to
allow migration of thread objects between QThreadManager's.
- added QThread::setGroup(), QThread::getGroup() to
allow collection of threads into groups
QThreadManager
the thread manager is used as a single interface for managing either single
threads, groups of threads or all threads for that manager.
- single global instance
- application specific QThreadManager's
- can be used to wait on all threads
- can be used to wait on groups of threads
- can be used to wait on single thread
i would have added additional functionality like the ability to cancel
a thread/groups of threads/all threads and the same for signalling them,
suspending them and resuming them, but those capabilities aren't gauranteed
across platforms (pthread doesn't support suspend/resume, windows doesn't
support signal/cancel).
QThreadKey<T>
the QThreadKey is a typesafe wrapper for thread local storage (thread
specific storage). essentially, you create the key as a static element of a
class that that will be used inside a thread context and assign some value to
it. currently, its being used inside Qt to hold a pointer to the current
thread ( QThreadKey<QThread *> ).
- automatic creation inside constructor
- automatic deletion inside destructor
- get()/set() to access or modifiy the value of the key.
- will not automatically destroy pointers stored in the key.
hopefully, Qt will commit these changes to 3.1 or some near future version of
qt. like i said before, if you're interested, let me know and i will send you
the files that i changed/added. i won't post them to the list though, because
its trolltech's decision on whether or not to use it. if you like the
changes, write trolltech and let them know that you found them a) useful b)
interesting c) stupid or d) lame.
also, if trolltech commits those changes, and i can find some spare time, i
plan on writing a kthread library that implements some oo patterns found in
the ACE toolkit for kde - specifically the active object stuff which is by
far some of the coolest code i've ever seen. whether or not you find it
useful is another story :)
thanks,
Andrew Sutton
ansutton@sep.com
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic