GroupItem Class

class Tasking::GroupItem

GroupItem represents the basic element that may be a part of any Group. More...

Header: #include <solutions/tasking/tasktree.h>
Inherited By:

Tasking::CustomTask and Tasking::Group

Public Types

Detailed Description

GroupItem is a basic element that may be a part of any Group. It encapsulates the functionality provided by any GroupItem's subclass. It is a value type and it is safe to copy the GroupItem instance, even when it is originally created via the subclass' constructor.

There are four main kinds of GroupItem:

GroupItem KindBrief Description
CustomTaskDefines asynchronous task type and task's start, done, and error handlers. Aliased with a unique task name, such as, ConcurrentCallTask<ResultType> or NetworkQueryTask. Asynchronous tasks are the main reason for using a task tree.
GroupA container for other group items. Since the group is of the GroupItem type, it's possible to nest it inside another group. The group is seen by its parent as a single asynchronous task.
StorageEnables the child tasks of a group to exchange data. When Storage is placed inside a group, the task tree instantiates the storage object just before the group is entered, and destroys it just after the group is finished.
Other group control itemsThe items returned by parallelLimit() or workflowPolicy() influence the group's behavior. The items returned by onGroupSetup(), onGroupDone() or onGroupError() define custom handlers called when the group starts or ends execution.

Member Type Documentation

[alias] GroupItem::GroupEndHandler

Type alias for std::function<void()>.

The GroupEndHandler is used when constructing the onGroupDone() and onGroupError() elements. Any function with the above signature, when passed as a group done or error handler, will be called by the running task tree when the group ends with success or an error, respectively.

See also onGroupDone() and onGroupError().

[alias] GroupItem::GroupSetupHandler

Type alias for std::function<SetupResult()>.

The GroupSetupHandler is used when constructing the onGroupSetup() element. Any function with the above signature, when passed as a group setup handler, will be called by the running task tree when the group execution starts.

The return value of the handler instructs the running group on how to proceed after the handler's invocation is finished. The default return value of SetupResult::Continue instructs the group to continue running, i.e. to start executing its child tasks. The return value of SetupResult::StopWithDone or SetupResult::StopWithError instructs the group to skip the child tasks' execution and finish immediately with success or an error, respectively.

When the return type is either SetupResult::StopWithDone of SetupResult::StopWithError, the group's done or error handler (if provided) is called synchronously immediately afterwards.

Note: Even if the group setup handler returns StopWithDone or StopWithError, one of the group's done or error handlers is invoked. This behavior differs from that of task handlers and might change in the future.

The onGroupSetup() accepts also functions in the shortened form of std::function<void()>, i.e. the return value is void. In this case it's assumed that the return value is SetupResult::Continue by default.

See also onGroupSetup().

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