[Development] Execute a function in the specified existing thread

JiDe Zhang zccrs at live.com
Tue Jul 4 08:06:28 CEST 2023


https://codereview.qt-project.org/c/qt/qtbase/+/489239

I have a patch to show my idea. I think it is worthwhile, you can provide an exists thread to QtConcurrent::run, isn't run the function in a new thread always.
________________________________
From: Volker Hilsheimer <volker.hilsheimer at qt.io>
Sent: Saturday, June 10, 2023 00:05
To: Macieira, Thiago <thiago.macieira at intel.com>; JiDe Zhang <zccrs at live.com>; development at qt-project.org <development at qt-project.org>
Subject: Re: [Development] Execute a function in the specified existing thread



On 9 Jun 2023, at 02:00, Thiago Macieira <thiago.macieira at intel.com> wrote:

On Wednesday, 7 June 2023 19:18:02 PDT JiDe Zhang wrote:
please make sure your contribution uses QMetaCallEvent.

Why uses QMetaCallEvent? I don't know how to make the function arguments to
void** for QMetaCallEvent constructor. Maybe I can use
QAbstractMetaCallEvent.

My point is that a contribution to QtCore should use the most efficient method
of getting the job done without undue complexity. That means I can accept
inefficiencies provided they make the code more readable & maintainable than
otherwise would have been, but not if they aren't justified.

As of https://codereview.qt-project.org/c/qt/qtbase/+/469799, creating a QMetaCallEvent is pretty straight-forward.

And creating the QCallableObject needed for that is also easier by the makeSlotObject helper, see https://codereview.qt-project.org/c/qt/qtbase/+/475547.

It’s still requires working with private APIs, but there’s a reason those APIs exist, and that they are private - there are many cases you want to support (functors and lambdas, member-function-pointers, free functions, move-only functors etc).

Volker

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230704/be4be133/attachment.htm>


More information about the Development mailing list