Great, thanks for the quick reply and confirmation.
One more question: Would you create one QThreadPool instance for the entire application or create new instances as you go (from within different modules). Does it matter?

Cheers,
frank

On 20/01/17 3:29 PM, Thiago Macieira wrote:
On sexta-feira, 20 de janeiro de 2017 11:59:31 PST Frank Rueter | OHUfx wrote:
Hi all,

I have started using QThreadPool for the first time and am wondering if
it's save/recommended to create my own instance of it or to always use
the global instance?
The rule I use is that you should use your own pool if you plan on launching
tasks that may block, but it's ok to use the global one if you need to run
things that run as fast as they can without blocking.

QHostInfo uses its own thread pool because it calls a blocking function that
is known to sometimes take 30 seconds to return (getaddrinfo).

In my case my app will run inside a host application, so my gut feeling
says to create my own thread pool so I don't accidentally hijack the
host application's pool, but I may be wrong?!
You're probably right. QHostInfo's example also matches your thinking: Qt's
behind-the-scenes usage should not affect the main application's ability to
use the global thread pool.


_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to