Results 1 to 3 of 3

Thread: what if qthread call same slot at the same time?

  1. #1
    Join Date
    Sep 2008
    Posts
    23
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question what if qthread call same slot at the same time?

    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

  2. #2
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: what if qthread call same slot at the same time?

    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?

  3. #3
    Join Date
    Jul 2008
    Posts
    47
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: what if qthread call same slot at the same time?

    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.

Similar Threads

  1. CPU Time & Memory Usage in QThread or QProcess
    By Davidaino in forum Qt Programming
    Replies: 0
    Last Post: 11th July 2008, 19:15
  2. Replies: 2
    Last Post: 8th October 2007, 15:02
  3. Replies: 6
    Last Post: 17th March 2006, 17:48

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.