ExecutableItem Class
class Tasking::ExecutableItemBase class for executable task items. More...
Header: | #include <solutions/tasking/tasktree.h> |
Inherits: | Tasking::GroupItem |
Inherited By: |
Note: All functions in this class are reentrant.
Public Functions
Tasking::Group | withLog(const QString &logName) const |
Tasking::Group | withTimeout(std::chrono::milliseconds timeout, const std::function<void ()> &handler = {}) const |
Related Non-Members
Tasking::Group | operator!(const Tasking::ExecutableItem &item) |
Tasking::Group | operator&&(const Tasking::ExecutableItem &first, const Tasking::ExecutableItem &second) |
Tasking::Group | operator&&(const Tasking::ExecutableItem &item, Tasking::DoneResult result) |
Tasking::Group | operator||(const Tasking::ExecutableItem &first, const Tasking::ExecutableItem &second) |
Tasking::Group | operator||(const Tasking::ExecutableItem &item, Tasking::DoneResult result) |
Detailed Description
ExecutableItem
provides an additional interface for items containing executable tasks. Use withTimeout() to attach a timeout to a task. Use withLog() to include debugging information about the task startup and the execution result.
Member Function Documentation
Tasking::Group 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.
The debug printout includes a timestamp of the event (start or finish) and logName to identify the specific task in the debug log.
The finish printout contains the additional information whether the execution was synchronous or asynchronous, its result (the value described by the DoneWith enum), and the total execution time in milliseconds.
Tasking::Group 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.
When the ExecutableItem finishes before timeout passes, the returned item finishes immediately with the task's result. Otherwise, handler is invoked (if provided), the task is canceled, and the returned item finishes with an error.
Related Non-Members
Tasking::Group operator!(const Tasking::ExecutableItem &item)
Returns a Group with the DoneResult of item negated.
If item reports DoneResult::Success, the returned item reports DoneResult::Error. If item reports DoneResult::Error, the returned item reports DoneResult::Success.
The returned item is equivalent to:
Group { item, onGroupDone([](DoneWith doneWith) { return toDoneResult(doneWith == DoneWith::Error); }) }
See also operator&&() and operator||().
Tasking::Group operator&&(const Tasking::ExecutableItem &first, const Tasking::ExecutableItem &second)
Returns a Group with first and second tasks merged with conjunction.
Both first and second tasks execute in sequence. If both tasks report DoneResult::Success, the returned item reports DoneResult::Success. Otherwise, the returned item reports DoneResult::Error.
The returned item is short-circuiting: if the first task reports DoneResult::Error, the second task is skipped, and the returned item reports DoneResult::Error immediately.
The returned item is equivalent to:
Group { stopOnError, first, second }
Note: Parallel execution of conjunction in a short-circuit manner can be achieved with the following code: Group { parallel, stopOnError, first, second }
. In this case: if the first finished task reports DoneResult::Error, the other task is canceled, and the group reports DoneResult::Error immediately.
See also operator||() and operator!().
Tasking::Group operator&&(const Tasking::ExecutableItem &item, Tasking::DoneResult result)
This function overloads ExecutableItem::operator&&().
Returns the item task if the result is DoneResult::Success; otherwise returns the item task with its done result tweaked to DoneResult::Error.
The task && DoneResult::Error
is an eqivalent to tweaking the task's done result into DoneResult::Error unconditionally.
Tasking::Group operator||(const Tasking::ExecutableItem &first, const Tasking::ExecutableItem &second)
Returns a Group with first and second tasks merged with disjunction.
Both first and second tasks execute in sequence. If both tasks report DoneResult::Error, the returned item reports DoneResult::Error. Otherwise, the returned item reports DoneResult::Success.
The returned item is short-circuiting: if the first task reports DoneResult::Success, the second task is skipped, and the returned item reports DoneResult::Success immediately.
The returned item is equivalent to:
Group { stopOnSuccess, first, second }
Note: Parallel execution of disjunction in a short-circuit manner can be achieved with the following code: Group { parallel, stopOnSuccess, first, second }
. In this case: if the first finished task reports DoneResult::Success, the other task is canceled, and the group reports DoneResult::Success immediately.
See also operator&&() and operator!().
Tasking::Group operator||(const Tasking::ExecutableItem &item, Tasking::DoneResult result)
This function overloads ExecutableItem::operator||().
Returns the item task if the result is DoneResult::Error; otherwise returns the item task with its done result tweaked to DoneResult::Success.
The task || DoneResult::Success
is an eqivalent to tweaking the task's done result into DoneResult::Success unconditionally.
Copyright © The Qt Company Ltd. and other contributors. 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.