Results 1 to 4 of 4

Thread: Does "emit" in the calling thread mean execution?

  1. #1
    Join Date
    Sep 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Does "emit" in the calling thread mean execution?

    Hello!
    I've some questions regarding "emit".
    (1) I've done a test and it seems to me that emitting a signal which is connected to a slot in the calling thread equals function call. Is this right?
    (2) Suppose we have thread A and thread B, and now thread A is in "exec()" loop. A signal which is connected to a slot in thread A is emitted from thread B. Then how does the system treat this signal? Is the event related to the signal added to thread A's event queue and not executed until the events before it are all processed?
    Thanks in advance!

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    508
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Does "emit" in the calling thread mean execution?

    Hi, see QObject::connect, especially the ConnectionType parameter.

    Ginsengelf

  3. #3
    Join Date
    Feb 2009
    Posts
    33
    Thanks
    6
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Does "emit" in the calling thread mean execution?

    I don't know the answer to your question but when designing my thread related code, the only thing I assume is that the order of the 'emit' calls stays the same as the order they were called in when being picked up by thread A's event loop. I always just assume the other types of events could happen before or after the slot is actually called following an 'emit'. Is there some reason you need the event order to be specified, or are you just wondering? If so, then it wouldn't be hard to force the events to be called in the correct order if there was a slot-call waiting in the event queue, but that may be working against the Qt "way" and thus bad design. I'm not sure.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does "emit" in the calling thread mean execution?

    Quote Originally Posted by nomadoro View Post
    (1) I've done a test and it seems to me that emitting a signal which is connected to a slot in the calling thread equals function call. Is this right?
    Yes, effectively it's a function call.

    (2) Suppose we have thread A and thread B, and now thread A is in "exec()" loop. A signal which is connected to a slot in thread A is emitted from thread B. Then how does the system treat this signal? Is the event related to the signal added to thread A's event queue and not executed until the events before it are all processed?
    Signal is emitted as usual in thread B. The emission procedure notices it has to deliver the signal to thread A so it transforms the signal into an event and posts it into destination thread's (A's) event loop.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Thread Ownership Problem
    By tntcoda in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 00:18
  2. "emit" keyword optional when calling signals?
    By will49 in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2008, 01:13
  3. Calling one new thread with in existing thread?
    By ashukla in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2007, 14:09
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. Replies: 10
    Last Post: 20th March 2007, 22:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.