QProcessDeleter Class
A custom deleter for QProcess, used by QProcessTask. More...
Header: | #include <qprocesstask.h> |
Note: All functions in this class are reentrant.
Public Functions
void | operator()(QProcess *process) |
Static Public Members
void | syncAll() |
Detailed Description
QProcessDeleter is used to enable fast destruction of running QProcess instances via QProcessTask in QTaskTree. Instead of deleting the running QProcess, which may block the caller's thread execution for a long time, the QProcessDeleter moves the running QProcess into a separate thread and tries to finish it in a most gentle way. This consist of calling QProcess::terminate() with 500 ms
timeout, and if the process is still running after this timeout passed, the additional call to QProcess::kill() is performed.
Finally, on application quit, QProcessDeleter::syncAll() should be called in order to synchronize all processes being still potentially finalized in separate thread. The call to QProcessDeleter::syncAll() is blocking in case some processes are still being finalized.
This strategy seems sensible, since when deleting the running QProcess via QProcessDeleter we don't block immediately, but postpone the possible (but not certain) block until the end of an application.
It is used by QProcessTask.
Member Function Documentation
[static]
void QProcessDeleter::syncAll()
This method should be called on application quit to synchronize the finalization of all still possibly running QProcess instances that were deleted before using QProcessDeleter. The call should be executed from the main thread.
void QProcessDeleter::operator()(QProcess *process)
Deletes the passed process in a most safe way. If the passed process is not running, it is deleted directly. Otherwise, it moves the process into a separate thread and tries to finish it in a most safe way by calling QProcess::terminate() with 500 ms
timeout, and if the process is still running after this timeout passed, the additional call to QProcess::kill() is performed.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.