[Qt-interest] concurrent-run of a static function

Mihail Naydenov mlists at ymail.com
Mon May 17 10:58:22 CEST 2010





----- Original Message ----
> From: K. Frank <kfrank29.c at gmail.com>
> To: Qt-interest <qt-interest at trolltech.com>
> Sent: Mon, May 17, 2010 12:41:26 AM
> Subject: Re: [Qt-interest] concurrent-run of a static function
> 
> Hello Gabriele -

...

You are generally correct in your assumptions.  


Also, let's say, 
> for the sake of argument, that doSomeImageWork were
a _static_ member 
> function of QImage.  You would still have to call it
this 
> way:

   QFuture<void> future =
      
> QtConcurrent::run (QImage::doSomeImageWork,  &image, arg2, arg3, 
> ...);

Because QImage::doSomeImageWork is a static member function, it is 
> not
associated with any specific instance of QImage (said another way, it 
> doesn't
have access to a "this" pointer), so you need to tell it with an 
> argument
(&image) which image (which instance of QImage) it is supposed 
> to work on.


As you said static functions dont have this pointer, why do you think it needs to be passed to run()?


To All:  Please help me fix what I've gotten wrong 
> here.  I am trying to learn
Qt, so I am using this as an opportunity to 
> learn something about QtConcurrent.

As for the question I mentioned 
> earlier:  How does Qt decide which version of
QtConcurrent::run() to 
> use?  As far as I know, it would have to be by
overloading
on the 
> argument types.  So what happens if I pass a function object (which 
> is
an instance of a class) as the first argument, and a 
> pointer-to-member-function
as the second argument?  Which version gets 
> called (or do I get an error, etc.)?


Yes, its overloading ( + templates). Only one param is the function to call, so the others are params to it.
Function objects are supported also, and they use a diff overload. Of course you get a compile error if mess the things up.

MihailNaydenov

PS. About "Understanding thread affinity -- some questions about a lengthy example"

It was exactly twice longer as my personal threshold :) May be if you split it and simplify (no need for  yyy : same analysis as for xxx ) it it will be answered. ALSO I recommend reading the examples coming with Qt and also the Qt Quarterly (http://doc.trolltech.com/qq/)
 

Thanks for any insight into 
> this.

> ...

> Regards,
> K. Gabriele

Good 
> luck.


K. 
> Frank
_______________________________________________
Qt-interest mailing 
> list

> href="mailto:Qt-interest at trolltech.com">Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


      



More information about the Qt-interest-old mailing list