If using QThread::yieldCurrentThread() after sending the signal, does the context switch still depend on the QThread::priority()?.You can't (nor should you be able to) force the scheduler to allocate a slice to a specific thread. No, because time slices in a multitasking system are controlled by the scheduler and after your slice's over then another thread/process can be activated, although you may get another slice. It is very said in QThread's time slice and signal/slot response: OTOH, is there any function like ucontext in Qt. If it starts running a slot at t=0ms and finishes at t=5ms, then it will start running the next slot at t=6ms. No, the event loop doesn't work like that. ![]() the slot can finish the job in 5ms, but the thread's time slice of this slot is 100ms, is the rest of time(95ms) wasted? They do not force a different thread to start running.Į.g. That will ensure that your main thread is always smooth running.Ĭound I use sleep() or QThread::yieldCurrentThread() to achieve this? I hope the main thread can be active as far as possible to ensure the smooth runningĪll you need to do is make sure that the functions in your main thread return quickly. You don't need to call processEvents().ĭo not put your own infinite loop (like while (true) ) in a thread that needs to receive signals. The thread's event loop actively processes the signals as fast as it can. If there is a loop, does it mean the receive thread will never respond the signal untill the loop over or using qApp::processEvents() in the loop
0 Comments
Leave a Reply. |