ThreadWeaver and asyncronous operations

Louai Al-Khanji louai.khanji at gmail.com
Wed Mar 28 22:03:32 BST 2007


On Wednesday 28 March 2007 20:19, Paulo Moura Guedes wrote:
> On Wednesday 28 March 2007 08:25, you wrote:
> > Hi Paulo,
> >
> > the reason is:
> >
> > * you create the job in your main thread
> > * this creates the timer in the main thread
>
> I'm not creating any timer in the main thread...
>
> > then the job is executed in one of the threads of threadweavers pool
> >
> > * this makes the QTimer think it still resides in the main thread, thus
> > the error message
> > * you need to create the timer once the job is executed, within the run
> > function, then it knows about its correct thread
>
> The timer is created after calling the async operation in the run() method,
> so the timer is not created on the the GUI thread.
> All objects are being created in the run() method or one of its childs with
> the exception of the job itself, like you said.
> I can't understand what is happening.
>
> Paulo

Hi,
I had a similar problem some time ago. For some reason creating the timer on 
the stack worked, while creating it on the heap did not (i.e. with new). I 
didn't look further into it.

Louai

>
> > The main difference between just using threads and using threadweaver is
> > that you do not own the thread, so you cannot moveToThread() the QObjects
> > you created.
> >
> > --Mirko.
> >
> > On Wednesday 28 March 2007 02:29, you wrote:
> > > This works.
> > >
> > > The only problem I noticed is that if the AsyncObject internals use
> > > timers, for example, I get the "QObject::startTimer: timers cannot be
> > > started from another thread" message.
> > > I don't understand this however, because the timers are ran in the same
> > > thread as the AsyncObject.
> > >
> > > If someone shed a light on this I would really appreciate.
> > >
> > > Paulo




More information about the kde-core-devel mailing list