[Interest] Qthread from QFuture?
Scott Bloom
scott at towel42.com
Wed Jan 5 16:39:58 CET 2022
Thanks for the info
~~Scott
-------- Original message --------
From: Thiago Macieira <thiago.macieira at intel.com>
Date: 1/5/22 4:31 AM (GMT-08:00)
To: interest at qt-project.org
Cc: Scott Bloom <scott at towel42.com>
Subject: Re: [Interest] Qthread from QFuture?
On Tuesday, 4 January 2022 22:01:20 -03 Scott Bloom wrote:
> I appreciate the information. However, I don’t understand why a QFuture
> created by QtConcurrent::run, if it can tell isRunning, why it cant return
> the QThread its using?
Because you don't have a use-case for using that pointer. What are you going
to do with it, since you don't own that thread? First of all, it's also a race
condition: the pointer may no longer be valid by the next instruction that you
run.
It belongs to the thread pool you started the job on, and the thread pool may
have more jobs to run. Obviously, the code that started that thread and is
running jobs expects the job to cleanly exit (via exceptions or return, but
still cleanly) so it can do its post-job maintenance on the thread and the job
count. If you killed the thread, that thing will go completely out of sync and
may crash or deadlock even harder.
> Unless there is simply no QThread, and its using all OS calls (which could
> make sense).
No, it's using QThread.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel DPG Cloud Engineering
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220105/643e70d7/attachment.htm>
More information about the Interest
mailing list