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 » MT again
MT again [message #24026] Fri, 18 December 2009 12:03 Go to previous message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
// calculation thread function
void CalcPage::DoCalculation(void)
{
	int mod;

	INTERLOCKED_(mutex)  {
		modified = false;
	}

	do
	{
		LOG(__FUNCTION__ << " Start calculation");
		// gets the status bar
		StatusBar &sb = ((Lamell *)(GetMainWindow()))->GetStatusBar();
		{
			// signals calculation in progress
			GuiLock __;
			sb.Set("Calcolo in corso");
		}
	
		calcAborted = !Calculate();
		{
			// signals end of calculation
			GuiLock __;
			if(calcAborted)
				sb.Set("Errore");
			else
				sb.Set("Pronto");
		}
		INTERLOCKED_(mutex) {
			mod = modified;
		}
		LOG(__FUNCTION__ << " End calculation, modified = " << mod);
	}
	while(mod);
}

// modify handler -- triggers page calculation
// on keypress on every (editable) ctrl on page
void CalcPage::ModifyCb(void)
{
	LOG(__FUNCTION__ << " ModifyCb called");
	if(!calcThread.IsOpen())
	{
		calcThread.Run(THISBACK(DoCalculation));
		return;
	}
	INTERLOCKED_(mutex) {
		modified = true;
	}
}


CalcPage::ModifyCb is called on every change on editables ctrls on page (editfields mostly)
DoCalculation thread should take in account changes on page that happens between calculations, and so it should recalc the whole stuff.

My results :
Sometimes it starts just once, then it's never run again (the calc thread), so I guess it's hanging somewhere
Sometimes it keeps recalculating, but ModifyCb is not reentered, so I'm quite sure that the modify flag is not recursively set because of calc routine.

First case happens mostly

Max
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HttpQuery - not working?
Next Topic: CGI-BIN bug with Apache Server
Goto Forum:
  


Current Time: Fri Mar 29 00:01:52 CET 2024

Total time taken to generate the page: 0.01591 seconds