On this page

QtTaskTree::ParallelLimit Class

class QtTaskTree::ParallelLimit

The parallel execution mode with a custom limit. More...

Header: #include <qtasktree.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS TaskTree)
target_link_libraries(mytarget PRIVATE Qt6::TaskTree)
qmake: QT += tasktree
Inherits: QtTaskTree::ExecutionMode

Note: All functions in this class are reentrant.

Public Functions

ParallelLimit(int limit)

Detailed Description

The limit defines the maximum number of direct child tasks running in parallel:

  • When limit equals to 0, there is no limit, and all direct child tasks are started together, in the oder in which they appear in a group. This means the fully parallel execution, and the parallel element may be used instead.
  • When limit equals to 1, it means that only one child task may run at the time. This means the sequential execution, and the sequential element may be used instead. In this case, child tasks run in chain, so the next child task starts after the previous child task has finished.
  • When other positive number is passed as limit, the group's child tasks run in parallel, but with a limited number of tasks running simultanously. The limit defines the maximum number of tasks running in parallel in a group. When the group is started, the first batch of tasks is started (the number of tasks in a batch equals to the passed limit, at most), while the others are kept waiting. When any running task finishes, the group starts the next remaining one, so that the limit of simultaneously running tasks inside a group isn't exceeded. This repeats on every child task's finish until all child tasks are started. This enables you to limit the maximum number of tasks that run simultaneously, for example if running too many processes might block the machine for a long time.

See also ExecutionMode.

Member Function Documentation

ParallelLimit::ParallelLimit(int limit)

Constructs a parallel execution mode with a given limit.

See also ExecutionMode.

© 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.