PDA

View Full Version : what if qthread call same slot at the same time?



zl2k
11th September 2008, 02:28
My main widget will launch qthread processes and each connected with the same slot. Upon the thread finishes, it will emit a signal and call the slot. My question is: what if multiple threads call the same slot nearly at the same time that the first call has not finished yet? Will the call queued? Will it automatically dropped if busy? Or it just do at the same time without considering any concurrency? (In this case, I guess I need to put a qmutex to hold the slot). I am worry if it's going to automatically be dropped.
Thanks for your comments.
zl2k

yxmaomao
11th September 2008, 06:50
Qt's slot just likes a normal thread function. they will be called at any time. if there was something in your thread you want to protect, then you need to use some synchoronize mechanism like qmutes etc. in your slot. Does this make sense?

muellerp
11th September 2008, 09:58
Any signal/slot in between any thread like mainthread/workerthreads are queued connections by default.

The slots are computed in the slot thread, not the signal thread.

So the slot in your mainthread is only computed within mainthread, so you don't need to care about reentrancy or concurrency in mainthread as the signals are queued and computed one after the other and no signal is dropped.