Home » U++ Library support » U++ MT-multithreading and servers » MT again
MT again [message #24026] |
Fri, 18 December 2009 12:03 |
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
|
|
|
Goto Forum:
Current Time: Sat May 11 16:22:23 CEST 2024
Total time taken to generate the page: 0.03052 seconds
|