[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: [PATCH] thread-safe KQueuedDialog episode 2
From: Sebastian Trueg <trueg () kde ! org>
Date: 2008-11-27 14:28:46
Message-ID: 492EAE9E.5050008 () kde ! org
[Download RAW message or body]
you are of course perfectly right. I have no idea why I did not put that
into the constructor. Will do. Other than that, patch ok?
Matthias Kretz wrote:
> Hi,
>
> On Thursday 27 November 2008 10:35:42 Sebastian Trueg wrote:
>> KDialogQueue* KDialogQueue::self()
>> {
>> K_GLOBAL_STATIC(KDialogQueue, _self)
>> +
>> + // we want KDialogQueue to be thread-safe, i.e. it should be possible
>> + // to queue dialogs from any thread, not only the GUI thread. For that
>> + // to work, the KDialogQueue has to live in the GUI thread. Only then
>> + // the queued connections used below will end up there.
>> + if(_self->thread() != QApplication::instance()->thread() &&
>> + _self->thread() == QThread::currentThread())
>> + _self->moveToThread(QApplication::instance()->thread());
>> +
>
> AFAICS you can move this code into the KDialogQueue constructor. That way
> you're guaranteed to get a KDialogQueue object that is linked to the GUI
> thread from all threads. Otherwise you have a race condition where two threads
> access this function, the non-GUI thread creates the object and the other
> thread starts to use it before the thread that created the object moves it to
> the GUI thread.
> Also you then have to do the thread affinity check only once instead of for
> every access.
>
>> return _self;
>> }
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic