Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
Tasking::Group Class Reference

\inheaderfile solutions/tasking/tasktree.h \inmodule TaskingSolution More...

#include <tasktree.h>

Inheritance diagram for Tasking::Group:
Collaboration diagram for Tasking::Group:

Public Member Functions

 Group (const GroupItems &children)
 Constructs a group with a given list of children.
 Group (std::initializer_list< GroupItem > children)
 Constructs a group from std::initializer_list given by children.
Public Member Functions inherited from Tasking::ExecutableItem
Group withTimeout (std::chrono::milliseconds timeout, const std::function< void()> &handler={}) const
 Attaches TimeoutTask to a copy of this ExecutableItem, elapsing after timeout in milliseconds, with an optionally provided timeout handler, and returns the coupled item.
Group withLog (const QString &logName) const
 Attaches a custom debug printout to a copy of this ExecutableItem, issued on task startup and after the task is finished, and returns the coupled item.
template<typename SenderSignalPairGetter>
Group withCancel (SenderSignalPairGetter &&getter, std::initializer_list< GroupItem > postCancelRecipe={}) const
template<typename SenderSignalPairGetter>
Group withAccept (SenderSignalPairGetter &&getter) const
Public Member Functions inherited from Tasking::GroupItem
template<typename StorageStruct>
 GroupItem (const Storage< StorageStruct > &storage)
 Constructs a GroupItem element holding the storage object.
 GroupItem (const GroupItems &children)
 Constructs a GroupItem element with a given list of items.
 GroupItem (std::initializer_list< GroupItem > children)

Static Public Member Functions

template<typename Handler>
static GroupItem onGroupSetup (Handler &&handler)
template<typename Handler>
static GroupItem onGroupDone (Handler &&handler, CallDoneIf callDoneIf=CallDoneIf::SuccessOrError)

Additional Inherited Members

Public Types inherited from Tasking::GroupItem
using GroupSetupHandler = std::function<SetupResult()>
using GroupDoneHandler = std::function<DoneResult(DoneWith)>
Protected Types inherited from Tasking::GroupItem
enum class  Type {
  List , Group , GroupData , Storage ,
  TaskHandler
}
using InterfaceCreateHandler = std::function<TaskInterface *(void)>
using InterfaceSetupHandler = std::function<SetupResult(TaskInterface &)>
using InterfaceDoneHandler = std::function<DoneResult(const TaskInterface &, DoneWith)>
Protected Member Functions inherited from Tasking::ExecutableItem
 ExecutableItem ()=default
 ExecutableItem (const TaskHandler &handler)
Protected Member Functions inherited from Tasking::GroupItem
 GroupItem (const Loop &loop)
 GroupItem ()=default
 GroupItem (Type type)
 GroupItem (const GroupData &data)
 GroupItem (const TaskHandler &handler)
void addChildren (const GroupItems &children)
Static Protected Member Functions inherited from Tasking::GroupItem
static GroupItem groupHandler (const GroupHandler &handler)
template<typename Result, typename Function, typename ... Args, typename DecayedFunction = std::decay_t<Function>>
static constexpr bool isInvocable ()

Detailed Description

\inheaderfile solutions/tasking/tasktree.h \inmodule TaskingSolution

Group represents the basic element for composing declarative recipes describing how to execute and handle a nested tree of asynchronous tasks. \reentrant

Group is a container for other group items. It encloses child tasks into one unit, which is seen by the group's parent as a single, asynchronous task. Since Group is of the GroupItem type, it may also be a child of Group.

Insert child tasks into the group by using aliased custom task names, such as, ConcurrentCallTask<ResultType> or NetworkQueryTask:

const Group group {
};
Group(const GroupItems &children)
Constructs a group with a given list of children.
Definition tasktree.h:350
CustomTask< ConcurrentCallTaskAdapter< T > > ConcurrentCallTask
SimpleCustomTask< NetworkQuery > NetworkQueryTask
GLboolean GLuint group
[16]

The group's behavior may be customized by inserting the items returned by \l {Tasking::parallelLimit()} {parallelLimit()} or \l {Tasking::workflowPolicy()} {workflowPolicy()} functions:

const Group group {
};
const GroupItem parallel
const GroupItem continueOnError

The group may contain nested groups:

The group may dynamically instantiate a custom storage structure, which may be used for inter-task data exchange:

const auto onFirstSetup = [](NetworkQuery &task) { ... };
const auto onFirstDone = [storage](const NetworkQuery &task) {
// storage-> gives a pointer to MyCustomStruct instance,
// created dynamically by the running task tree.
storage->data = task.reply()->readAll();
};
const auto onSecondSetup = [storage](ConcurrentCall<QImage> &task) {
// storage-> gives a pointer to MyCustomStruct. Since the group is sequential,
// the stored MyCustomStruct was already updated inside the onFirstDone handler.
const QByteArray storedData = storage->data;
};
const Group group {
// When the group is entered by a running task tree, it creates MyCustomStruct
// instance dynamically. It is later accessible from all handlers via
// the *storage or storage-> operators.
storage,
NetworkQueryTask(onFirstSetup, onFirstDone, CallDoneIf::Success),
};
\inmodule QtCore
Definition qbytearray.h:58
\inheaderfile solutions/tasking/tasktree.h \inmodule TaskingSolution
Definition tasktree.h:198
const GroupItem sequential
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
[0]

Definition at line 347 of file tasktree.h.

Constructor & Destructor Documentation

◆ Group() [1/2]

Tasking::Group::Group ( const GroupItems & children)
inline

Constructs a group with a given list of children.

This constructor is useful when the child items of the group are not known at compile time, but later, at runtime:

const QStringList sourceList = ...;
GroupItems groupItems { parallel };
for (const QString &source : sourceList) {
const NetworkQueryTask task(...); // use source for setup handler
groupItems << task;
}
const Group group(groupItems);
\inmodule QtCore
QList< GroupItem > GroupItems
Definition tasktree.h:36
GLsizei GLsizei GLchar * source

Definition at line 350 of file tasktree.h.

◆ Group() [2/2]

Tasking::Group::Group ( std::initializer_list< GroupItem > children)
inline

Constructs a group from std::initializer_list given by children.

This constructor is useful when all child items of the group are known at compile time:

Definition at line 351 of file tasktree.h.

Member Function Documentation

◆ onGroupDone()

template<typename Handler>
GroupItem Tasking::Group::onGroupDone ( Handler && handler,
CallDoneIf callDoneIf = CallDoneIf::SuccessOrError )
inlinestatic

Definition at line 359 of file tasktree.h.

References Tasking::GroupItem::groupHandler().

Here is the call graph for this function:

◆ onGroupSetup()

template<typename Handler>
GroupItem Tasking::Group::onGroupSetup ( Handler && handler)
inlinestatic

Definition at line 355 of file tasktree.h.

References Tasking::GroupItem::groupHandler().

Here is the call graph for this function:

The documentation for this class was generated from the following files: