[Interest] Which thread implementation is best to trigger external library via timers

Thiago Macieira thiago.macieira at intel.com
Thu Apr 10 17:13:56 CEST 2014


Em qui 10 abr 2014, às 09:42:25, Roland Winklmeier escreveu:
> 1. Subclassing QThread: I've read you should avoid that, so I don't really
> consider it
> 2. Move it to thread: networkWorker->moveToThread(thread);
> 3. High level API's: QtConcurrent/QRunning
> 
> The requirements are:
> - Run infinite - stop only when requested
> - Needs to run threads event loop
> - Able to call slots via queued events
> and the most critical part
> - direct function calls synchronized via Mutexes from main thread

Go for option 1:

void ThreadClass::run()
{
	forever {
		DoTask();
		sleep(1);
	}
}

It's horrible, but not because of QThread.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list