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 app hangs
MT app hangs [message #23995] Wed, 16 December 2009 00:29 Go to previous message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
This app :
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class TestThread : public TopWindow
{
	protected:
		bool stop;
		void buttonCb(void);
		Thread thr;
		virtual void thrCb(void);
		
		ProgressIndicator progress;
		Button button;
		StatusBar status;
		
	public:
		typedef TestThread CLASSNAME;

		TestThread();

};

void TestThread::thrCb(void)
{
	{
		GuiLock __;
		status.Set("Running, " + FormatInt(thr.GetCount()) + " threads");
	}
	for(;;)
	{
		{
			GuiLock __;
			if(progress < 100)
				progress++;
			else
				progress = 0;
			if(stop)
				break;
		}
		usleep(100000);
	}
	{
		GuiLock __;
		status.Set("Idle....");
	}
}

void TestThread::buttonCb(void)
{
	if(stop)
	{
		stop = false;
		button.SetLabel("STOP");
		thr.Run(THISBACK(thrCb));
	}
	else
	{
		stop = true;
		thr.Wait();
		button.SetLabel("START");
	}
	
}

TestThread::TestThread()
{
	SetRect(0, 0, 300, 150);
	Add(button);
	button.TopPos(90, 30).HCenterPos(100);
	button.SetLabel("START");
	Add(progress);
	progress.TopPos(30, 40).HCenterPos(250);
	progress.Set(0, 100);
	AddFrame(status);
	status.Set(" ");

	stop = true;
	button <<= THISBACK(buttonCb);
		
}

GUI_APP_MAIN
{
	TestThread().Run();
}


Hangs on "thr.Wait()" line.
Removing the Wait line the app seems work, but, as far as I can see, it leaves the thread callback running (but blocked somehow...); the tread count shows erroneously the correct runnung thread count.
Looking deeper inside, the app seems to hang on callback return.

If I remove the callback code (but leave the empty callback function) the app behaves good.
In another non-gui testcase the app behaves also good.

Do I miss something or it's a bug ?

Ciao

Max

p.s.: ubuntu karmic, gcc 4.4.1

[Updated on: Wed, 16 December 2009 00:32]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MT.cpp __thread sMain related CRASH in VB6 project
Next Topic: Socket through Proxy server
Goto Forum:
  


Current Time: Sat Apr 27 01:53:36 CEST 2024

Total time taken to generate the page: 0.05556 seconds