[Qt-interest] Create a new GUI Thread
Thiago Macieira
thiago.macieira at trolltech.com
Tue Mar 10 03:05:34 CET 2009
Luke Campagnola wrote:
>I thought that might be the case, but I'm pretty surprised by it--why
> should X11 care whether two windows are controlled by two separate
> processes or by two threads in the same process?
The X11 protocol and the X11 server don't care.
libX11.so, however, does. And there's where the problem lies.
That library was not designed when threads were common-place. It provides
no locking primitives. And since the X11 operations must be serialised
onto a socket (shared by all threads), if two threads try to send at the
same time, there will be synchronisation problems.
Also note that the main thread will keep polling the X11 socket and
popping events off its stack. So, an operation in another thread that
requires sending and receiving from the X server also needs to make sure
no other threads are waiting for data.
Like I said, that library has no such API. Its replacement (libxcb) does,
but porting Qt to XCB would be no small task. Not to mention that XCB will
probably not be present in the Unix systems that are not based on X.org.
Finally, you said your problem is that your GUI operations can't fit in
one single core. I strongly urge you to reconsider your design: even if
you can split it over two threads, you have to remember that there are
people out there running systems with single cores, or people who run
other busy programs on their systems.
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Software
Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090309/1bb943d6/attachment.bin
More information about the Qt-interest-old
mailing list