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 » Need a suggestion about mouse processing inside threads
Re: Need a suggestion about mouse processing inside threads [message #34815 is a reply to message #34800] Tue, 13 December 2011 17:47 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13976
Registered: November 2005
Ultimate Member
From what I see, the only thing you need is to synchronize is your commandline. So just create Mutex for reading/writing to commandline...

Not that you will have to make a copy when reading it...

void UppCadDocument::commandLoop(void)
{
	// loop not ended
	INTERLOCKED_(mutex)
	{
		loopEnded = false;
	}
	while(!Thread::IsShutdownThreads())
	{
            String currentCommand;
            {
                Mutex::Lock __(commandLineMutex)
	        currentCommand = commandLine;
            }
		if(currentCommand.HasCommand())
		{
			String cmd = currentCommand.GetCommand();
			if(cmd != "<ESC>" && cmd != "")
				SendCommand(cmd);
		}
		Sleep(100);
	}
	// loop ended
	INTERLOCKED_(mutex)
	{
		loopEnded = true;
	}
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Multi-Thread Critial Section Problem
Next Topic: Htmls / HtamlTag class and table generation
Goto Forum:
  


Current Time: Thu May 09 17:42:44 CEST 2024

Total time taken to generate the page: 0.01976 seconds