QtTaskTree::ParallelLimit Class | Qt TaskTree | Qt 6.11.1
Description: The parallel execution mode with a custom limit.

- Qt 6.11
- Qt TaskTree
- C++ Classes
- ParallelLimit
- Qt 6.11.1 Reference Documentation

# 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`
Since: | Qt 6.11
Inherits: | QtTaskTree::ExecutionMode

- List of all members, including inherited members

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.