Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

'const' issue with run_and_wait member-function

Max_B_
Beginner
502 Views

I've encountered an issue where, although

g.run( f );

will compile fine,

g.run_and_wait( f );

causes my build to fail. The 'f' variable is an instance of a class with a defined public operator()(). The issue doesn't arise if I wrap 'f' away in a lambda. The issue seems to have something to do with const-correctness. Is this intended?

I've attached a small program which demonstrates the problem. I've tested only in Visual Studio 2010.

0 Kudos
5 Replies
Aleksei_F_Intel
Employee
502 Views

Yes, that's correct. The implementation of task group interface requires the user's functor to be cv-qualified as 'const'. Please see the details in the documentation available at https://www.threadingbuildingblocks.org/docs/help/reference/task_groups.htm

The reason why it works using lambda-based approach is because the lambda functions are implicitly declared with such 'const' qualifier by default, as far as I know.

0 Kudos
Max_B_
Beginner
502 Views

The first fragment I quoted above does compile, though.

Shouldn't the rules apply equally to run and run_and_wait?

0 Kudos
Aleksei_F_Intel
Employee
502 Views

They should. Thank you for reporting discrepancies!

0 Kudos
Max_B_
Beginner
502 Views

My pleasure.

Just so I'm clear, is creating a new forum thread the best way to report suspected bugs?

0 Kudos
Aleksei_F_Intel
Employee
502 Views

You are welcome!

Yes, forum is used to discuss issues, for technical support, or to report bugs. In addition, one could go further and submit a contribution (using https://www.threadingbuildingblocks.org/submit-contribution) to fix the suspected bug.

0 Kudos
Reply