Results 1 to 5 of 5

Thread: Threads and slots

  1. #1
    Join Date
    Sep 2007
    Location
    Germany
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Threads and slots

    Hi to all,

    I have a mess in my head(and almost sure iin my code as well), i have around 6 working thread that push information to a controller thread using signal slot(QueuedConnection). the thread are similar just read info from different devices, so the signals are the same prototype. the signals from this thread are connected to single slot in the controller. the controller uses mutx in this slots cause critical data. my question is what happen with the signals in the mean time the controller thread is working on the analisis of the info from one of the working threads.

    The signals are emmited really often.
    CAFU......

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Threads and slots

    The signals are queued until your threads handle them. Signals and slots are thread safe.

  3. #3
    Join Date
    Sep 2007
    Location
    Germany
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Threads and slots

    Thanks, i got it to work as i wanted, i was using to many threads with no reason, but this clear my mind
    CAFU......

  4. #4
    Join Date
    Sep 2007
    Location
    Germany
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Threads and slots

    One more Question how can i Know if i am creating to many threads? even if they work properly together, at leat aparently
    Last edited by cafu; 15th March 2010 at 11:34.
    CAFU......

  5. #5
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Threads and slots

    You have too many threads when
    # you loose overview
    # scheduling overhead slows the application down

    When having tasks that need to be done, I always prefer a thread pool (threads handling scheduled tasks).

    There's a pretty decent article on having too many threads and task based programming at http://www.codeguru.com/cpp/misc/mis...cle.php/c13533
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. threads, signals and slots
    By cyclic in forum Qt Programming
    Replies: 6
    Last Post: 2nd September 2009, 10:44
  2. Signals and Slots Across Threads
    By themusicalguy in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2007, 12:16
  3. signals/slots across threads
    By high_flyer in forum Qt Programming
    Replies: 9
    Last Post: 13th March 2007, 00:56
  4. signal/slots across threads in Qt4
    By Ambiorix in forum Qt Programming
    Replies: 7
    Last Post: 31st July 2006, 09:05
  5. [QT4] threads, signals, and slots, please help.
    By ucntcme in forum Qt Programming
    Replies: 12
    Last Post: 25th January 2006, 15:23

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.