Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » CoWork usage question
Re: CoWork usage question [message #51098 is a reply to message #51092] Wed, 23 January 2019 15:32 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Tue, 22 January 2019 15:15
Well, the second cup of coffee solved it for me:
		CoWork co;
		for(int i=0;i<ICOUNT;i++){
			//co & [&, i] { operation(ib[i]); }; // Reference variant
			co & [&, i] { operationp(&ib[i]); }; // Pointer variant
		}
		co.Finish();


Must have 'copy capture' for i, or otherwise the index i will run away before used.

Sorry for bothering with such trivial issue.

Best regards,

Tom


Yeah, got caught there too...

BTW, have you noticed the looper variant?

CoWork co;
co & [&] {
   for(;;) {
      int i = co.GetNext();
      if(i >= ICOUNT) break;
      operationp(&ib[i]);
   }
}


It is faster and more resilient w.r.t. those issues.

Mirek
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Does anyone have experience with dual booting on a notebook with recovery partition?
Next Topic: The eternal quarrel between Python and C
Goto Forum:
  


Current Time: Wed Apr 24 01:20:38 CEST 2024

Total time taken to generate the page: 0.04782 seconds