![]() |
Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
\inheaderfile solutions/tasking/tasktree.h \inmodule TaskingSolution More...
#include <tasktree.h>
Public Types | |
using | Task = typename Adapter::TaskType |
using | Deleter = typename Adapter::DeleterType |
using | TaskSetupHandler = std::function<SetupResult(Task &)> |
using | TaskDoneHandler = std::function<DoneResult(const Task &, DoneWith)> |
![]() | |
using | GroupSetupHandler = std::function<SetupResult()> |
using | GroupDoneHandler = std::function<DoneResult(DoneWith)> |
Public Member Functions | |
template<typename SetupHandler = TaskSetupHandler, typename DoneHandler = TaskDoneHandler> | |
CustomTask (SetupHandler &&setup=TaskSetupHandler(), DoneHandler &&done=TaskDoneHandler(), CallDoneIf callDoneIf=CallDoneIf::SuccessOrError) | |
\typealias CustomTask::Task | |
![]() | |
ExecutableItem | 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. | |
ExecutableItem | 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 > | |
ExecutableItem | withCancel (SenderSignalPairGetter &&getter) const |
![]() | |
template<typename StorageStruct > | |
GroupItem (const Storage< StorageStruct > &storage) | |
Constructs a GroupItem element holding the storage object. | |
GroupItem (const Loop &loop) | |
GroupItem (const QList< GroupItem > &children) | |
Constructs a GroupItem element with a given list of items. | |
GroupItem (std::initializer_list< GroupItem > children) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Additional Inherited Members | |
![]() | |
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)> |
![]() | |
ExecutableItem ()=default | |
ExecutableItem (const TaskHandler &handler) | |
![]() | |
GroupItem ()=default | |
GroupItem (Type type) | |
GroupItem (const GroupData &data) | |
GroupItem (const TaskHandler &handler) | |
void | addChildren (const QList< GroupItem > &children) |
![]() | |
static GroupItem | groupHandler (const GroupHandler &handler) |
static GroupItem | parallelLimit (int limit) |
static GroupItem | workflowPolicy (WorkflowPolicy policy) |
template<typename Result , typename Function , typename ... Args, typename DecayedFunction = std::decay_t<Function>> | |
static constexpr bool | isInvocable () |
\inheaderfile solutions/tasking/tasktree.h \inmodule TaskingSolution
A class template used for declaring custom task items and defining their setup and done handlers. \reentrant
Describes custom task items within task tree recipes.
Custom task names are aliased with unique names using the CustomTask
template with a given TaskAdapter subclass as a template parameter. For example, ConcurrentCallTask<T>
is an alias to the CustomTask
that is defined to work with ConcurrentCall<T>
as an associated task class. The following table contains example custom tasks and their associated task classes:
\table \header
std::chrono::milliseconds
Definition at line 467 of file tasktree.h.
using Tasking::CustomTask< Adapter >::Deleter = typename Adapter::DeleterType |
Definition at line 471 of file tasktree.h.
using Tasking::CustomTask< Adapter >::Task = typename Adapter::TaskType |
Definition at line 470 of file tasktree.h.
using Tasking::CustomTask< Adapter >::TaskDoneHandler = std::function<DoneResult(const Task &, DoneWith)> |
Definition at line 476 of file tasktree.h.
using Tasking::CustomTask< Adapter >::TaskSetupHandler = std::function<SetupResult(Task &)> |
Definition at line 475 of file tasktree.h.
|
inline |
\typealias CustomTask::Task
Type alias for the task type associated with the custom task's Adapter
.
\typealias CustomTask::Deleter
Type alias for the task's type deleter associated with the custom task's Adapter
.
\typealias CustomTask::TaskSetupHandler
Type alias for std::function<SetupResult(Task &)>
.
The TaskSetupHandler
is an optional argument of a custom task element's constructor. Any function with the above signature, when passed as a task setup handler, will be called by the running task tree after the task is created and before it is started.
Inside the body of the handler, you may configure the task according to your needs. The additional parameters, including storages, may be passed to the handler via the lambda capture. You can decide dynamically whether the task should be started or skipped with success or an error.
The return value of the handler instructs the running task tree on how to proceed after the handler's invocation is finished. The return value of SetupResult::Continue instructs the task tree to continue running, that is, to execute the associated Task
. The return value of SetupResult::StopWithSuccess or SetupResult::StopWithError instructs the task tree to skip the task's execution and finish it immediately with success or an error, respectively.
When the return type is either SetupResult::StopWithSuccess or SetupResult::StopWithError, the task's done handler (if provided) isn't called afterwards.
The constructor of a custom task accepts also functions in the shortened form of std::function<void(Task &)>
, that is, the return value is void
. In this case, it's assumed that the return value is SetupResult::Continue.
\typealias CustomTask::TaskDoneHandler
Type alias for std::function<DoneResult(const Task &, DoneWith)>
.
The TaskDoneHandler
is an optional argument of a custom task element's constructor. Any function with the above signature, when passed as a task done handler, will be called by the running task tree after the task execution finished and before the final result of the execution is reported back to the parent group.
Inside the body of the handler you may retrieve the final data from the finished task. The additional parameters, including storages, may be passed to the handler via the lambda capture. It is also possible to decide dynamically whether the task should finish with its return value, or the final result should be tweaked.
The DoneWith argument is optional and your done handler may omit it. When provided, it holds the info about the final result of a task that will be reported to its parent.
If you do not plan to read any data from the finished task, you may omit the {const
Task &} argument.
The returned DoneResult value is optional and your handler may return void
instead. In this case, the final result of the task will be equal to the value indicated by the DoneWith argument. When the handler returns the DoneResult value, the task's final result may be tweaked inside the done handler's body by the returned value.
Constructs a CustomTask
instance and attaches the setup and done handlers to the task. When the running task tree is about to start the task, it instantiates the associated \l Task object, invokes setup handler with a reference to the created task, and starts it. When the running task finishes, the task tree invokes a done handler, with a const
reference to the created task.
The passed setup handler is of the \l TaskSetupHandler type. For example:
The done handler is of the \l TaskDoneHandler type. By default, the done handler is invoked whenever the task finishes. Pass a non-default value for the callDoneIf argument when you want the handler to be called only on a successful or failed execution.
Definition at line 479 of file tasktree.h.
References done.