Multithreaded QLocalSocket
Sebastian Trüg
strueg at mandriva.com
Mon Jun 30 15:34:08 BST 2008
On Monday 30 June 2008 16:17:40 Thiago Macieira wrote:
> Sebastian Trüg wrote:
> >On Sunday 29 June 2008 14:19:21 Kevin Krammer wrote:
> >> On Sunday 29 June 2008, Sebastian Trüg wrote:
> >> > Apparently on Unix QLocalSocket uses QTcpSocket internally. This
> >> > results in a big problem when I want to use it in a multithreaded
> >> > environment as I cannot move the internal QTcpSocket to the new
> >> > thread. Does anyone have an idea on how to solve this issue? On how
> >> > to use QLocalSocket in multithreaded systems?
> >>
> >> On the server or the client side?
> >>
> >> On the client side you could use one QLocalSocket per thread.
> >>
> >> On the server side you can use the incomingConnection(quintptr)
> >> template method of QLocalServer and create the actual QLocalSocket in
> >> the target thread's context. We do this in Akonadi, see
> >> kdesupport/akonadi/server/src/akonadi.cpp and
> >> kdesupport/akonadi/server/src/akonadiconnection.cpp
> >
> >Thanks a lot for the hints. Seems to work. :)
>
> You should also be able to use the nextPendingConnection() method of
> QLocalServer and push it to the thread that will do the work with
> moveToThread().
I will try that on the server side. The urgent one was the client.
I think I already tried it on the server side, but maybe something changed or
I did it wrong back then. We will see.
Anyway, thanks a lot. Soon the Nepomuk storage should be fully multi-threaded
again and, thus, faster.
Cheers,
Sebastian
More information about the kde-core-devel
mailing list