[Interest] Poor QMethod::invoke performance across threads on i.MX53
Thiago Macieira
thiago.macieira at intel.com
Thu May 28 00:36:50 CEST 2015
On Wednesday 27 May 2015 17:16:54 Matthew Woehlke wrote:
> Right. An example probably helps. What's wrong with this approach?
>
> class MyThread : public QThread { ... } // has moveToThread(this)
>
> int main()
> {
> auto* t = new MyThread;
> t.start();
> // ...
> t.wait();
> delete t; // QThread deleted from main thread, not itself
> }
You cannot delete t; while the t object is associated with the other thread.
Do you have a moveToThread(nullptr) or moveToThread(mainThread)? If so, where?
That's what my examples were trying to show.
> The QThread is memory-managed from a thread other than itself. It's just
> that the thread affinity is circular. Note that I am *NOT* trying to
> deleteLater the QObject! (Because, yes, that would be horrible! And for
> that matter, would leak, since in my usage, the thread has exited before
> I try to delete it.)
>
> Anyway, a more accurate depiction of my case is:
>
> class MyThread : public QObject
> {
> QThread self;
> MyThread() { moveToThread(self); }
> }
>
> ...where again, it is assumed that MyThread is deleted from a thread
> other than MyThread::self. Is this approach broken? (I think no? It
> seems similar to the alternate approach you gave.)
Again missing the move-back.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list