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 » U++ Library support » U++ MT-multithreading and servers » AsyncWork, IsFinished() may not be working properly
Re: AsyncWork, IsFinished() may not be working properly [message #54428 is a reply to message #54427] Sat, 18 July 2020 07:51 Go to previous messageGo to previous message
JeyCi is currently offline  JeyCi
Messages: 50
Registered: July 2020
Member
I found below code seems working good - without Race_Condition - (in u++ v.13068 windows x32)...
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_FILE|LOG_COUT);
	
	Array<AsyncWork<int>> workers;
	
	// add worker
	for(int i = 0; i < 4; i++) {
		workers.Add() = Async([=]{ LOG("Started, worker #" << i); return i; });
	}
	
	Sleep(10);		//10/1000sec
	for (auto &fut : workers) {
		LOG("Stopped, worker #" << fut.Get());
	}
}

? BUT I wonder if there is a way to use atomic to counter to avoid race condition in the mirek's code?.. because any way I tried to use it (I mean Atomic in his code) - I have been still getting race condition Sad

[Updated on: Sat, 18 July 2020 07:53]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Skylark session verification
Next Topic: How do I create a loop for a window to react to volatile changes to a global variable?
Goto Forum:
  


Current Time: Sun Apr 28 05:44:53 CEST 2024

Total time taken to generate the page: 1.06228 seconds