[Qt-interest] Send signal from one thread to another (all threads sends in one loop)

Thiago Macieira thiago at kde.org
Thu Jun 23 16:56:24 CEST 2011


On Thursday, 23 de June de 2011 17:05:38 Николай Шатохин wrote:
> Hello.
> 
> I have server that creates new thread for every incoming connection
> (and gives unique id for every thread). I need to send signal from one
> thread to slot in another thread. How can I do this? Now, I send
> signal with receiver's id from thread to slot in server and server
> send signals to slots in every thread. Threads compare their ids with
> receiver's id and if they match - run code in slot. It works but maybe
> exists simplest method? How to send signal from one thread to slot in
> another directly? I will glad if somebody shows me example of source.

Why do you need to signal the thread? Do you want the thread to exit?

I don't think you want to signal the thread. You want to signal an object in 
the thread. Besides, if you have the thread ID, why do you want all threads to 
check if they were the intended one? Why don't you just tell the intended 
target object that it has work to do?

I think you're asking for the simple producer-consumer case that has an 
example in Qt.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110623/9dce8b1b/attachment.bin 


More information about the Qt-interest-old mailing list