diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-10-08 14:10:08 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2021-10-13 09:57:00 +0000 |
commit | 6444868ff5f95e868471d16f61ca3d0696bbd8a5 (patch) | |
tree | e1a6f1f1b8e6e7abf967bd36cd9cc30a10f30775 /src/imports/bluetooth/qdeclarativebluetoothservice.cpp | |
parent | 571b9ee1f7ae42ccb220ae6314d4fa73dc9884cb (diff) |
Refactor characteristics read for WinRT
The characteristics read was using IAsyncOperation->put_Completed() to
process the results of descriptor reading. Each of these completed
callbacks is executed in its own thread. In our case each of the
callbacks is also calling QWinRTFunctions::await() to perform some
async operations.
As a result, if the service has a lot of characteristics, we could
end up spawning multiple threads, each of them doing some CPU-consuming
operations. Normally it's not a problem, but looks like for some
bluetooth peripherals reading the characteristics can take significant
time. Connecting to such devices can result in 100% CPU load for all
cores if the number of characteristics exceeds the number of logical
CPUs.
This patch removes the put_Completed() approach in favor of another
QWinRTFunctions::async() call. This will guarantee that all the
characteristics read operations are performed in the same worker
thread. As a drawback, characteristics reading becomes sequential,
which makes it slower.
Fixes: QTBUG-97242
Change-Id: If46c3f0afe13a56d93f2b8fc46b87a2c90555bf3
(cherry picked from commit 2a7ef291d696745887e71f8b0e27cb4c8701bdd2)
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/imports/bluetooth/qdeclarativebluetoothservice.cpp')
0 files changed, 0 insertions, 0 deletions