Results 1 to 6 of 6

Thread: QThreadPool search threads

  1. #1
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    1

    Default QThreadPool search threads

    I have a main application that needs to handle multiple threads. I have stored the different threads in a QThreadPool which then handles the execution. But I need to access specific threads from this pool either from the main application that contains the QThreadPool (which might be easier to accomplish) or from the single threads directly.

    Is it possible to access a specific thread when using QTreadPool or do I have to use something else instead?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QThreadPool search threads

    The usual purpose of a thread pool is to make handling of individual threads unnecessary.

    What exactly are you trying to do that instantes this requirement?

    Cheers,
    _

  3. #3
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    1

    Default Re: QThreadPool search threads

    I have a server that accepts different clients. Every client is handled in a different thread. The clients should be able to send messages between them, therefore they need to be able to access a specific thread

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QThreadPool search threads

    Aside from the obvious question of why you need separate threads to handle client connections, why does one client handler need to know about another client handler's thread?

    Cheers,
    _

  5. #5
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    1

    Default Re: QThreadPool search threads

    As I mentioned above it is one of the solutions I came up, but I am open for suggestions if there is a better way to do it.
    Nevertheless I will have to access a specific thread/Client from the server then to be able to forward the received message from one client, or not??
    How else would I send the messages between the clients?

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QThreadPool search threads

    Quote Originally Posted by Cerberus View Post
    As I mentioned above it is one of the solutions I came up, but I am open for suggestions if there is a better way to do it.
    Unless you expect complex and CPU intensive tasks on each client handler, you could simply handle them with the same thread.

    Quote Originally Posted by Cerberus View Post
    Nevertheless I will have to access a specific thread/Client from the server then to be able to forward the received message from one client, or not??
    You write "thread/Client" but those two things are not the same.
    So far you have only provided indication that you need to access client handlers, but there is nothing suggesting you need access to a client handler's thread.

    Quote Originally Posted by Cerberus View Post
    How else would I send the messages between the clients?
    Same as in a single threaded application:
    - method call
    - signal/slot connection
    - sending an event

    None of which require access to any specific thread.

    Cheers,
    _

Similar Threads

  1. QThreadPool - how to remove all threads
    By ZioCanguro in forum Qt Programming
    Replies: 8
    Last Post: 6th September 2016, 18:58
  2. Replies: 1
    Last Post: 14th November 2012, 21:00
  3. Use QRunnable without QThreadPool
    By Qiieha in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2011, 10:02
  4. QEventLoop and QThreadPool Shutdown Problems
    By shawno in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2010, 18:49
  5. QThreadPool and QRunnable
    By jimc1200 in forum Qt Programming
    Replies: 3
    Last Post: 6th May 2009, 10:43

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.