Results 1 to 8 of 8

Thread: Many Many (most of the time sleeping) threads. Best approach?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2015
    Posts
    8
    Thanks
    3

    Default Re: Many Many (most of the time sleeping) threads. Best approach?

    Quote Originally Posted by wysota View Post
    Or subclass QObject, implement each agent in that class and make them event-driven. Then you can either run all of them in a single thread or spawn a number of extra threads and move agent objects to different threads.
    So for implementing this approach, you mean for example:

    - Implementing the agents just as QObject.
    - Add a battery of signal and slots for it to use by itself.
    - Once started instead of sleeping, use a timer to invoke later a signal of its own?

    Would this 10000 timers waiting for certain time to pass be a problem?

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

    Default Re: Many Many (most of the time sleeping) threads. Best approach?

    Quote Originally Posted by ander.pijoan View Post
    - Once started instead of sleeping, use a timer to invoke later a signal of its own?
    Either that or rely on events (if the agent should respond upon some other agent's actions).

    Would this 10000 timers waiting for certain time to pass be a problem?
    No but I wouldn't do that. It's better that the object do "nothing". You can have one timer and connect every agent to that timer to provide a kind of "heartbeat" impulse.
    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.


  3. The following user says thank you to wysota for this useful post:

    ander.pijoan (21st April 2015)

  4. #3
    Join Date
    Apr 2015
    Posts
    8
    Thanks
    3

    Smile Re: Many Many (most of the time sleeping) threads. Best approach?

    Worked really well your proposed solution, thanks again

Similar Threads

  1. Replies: 2
    Last Post: 14th December 2011, 10:11
  2. Best approach to set a itemdelegate strategy?
    By tonnot in forum Qt Programming
    Replies: 0
    Last Post: 31st October 2011, 17:49
  3. Qt Threads vs Native Threads performance
    By StackOverflow in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2010, 13:14
  4. thread - right approach?
    By heinz32 in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2008, 18:39
  5. what is the best approach
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 10:02

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.