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::ExecutableItem Class Reference

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

#include <tasktree.h>

Inheritance diagram for Tasking::ExecutableItem:
Collaboration diagram for Tasking::ExecutableItem:

Public Member Functions

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)

Protected Member Functions

 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)

Friends

TASKING_EXPORT friend Group operator! (const ExecutableItem &item)
 Returns a Group with the DoneResult of item negated.
TASKING_EXPORT friend Group operator&& (const ExecutableItem &first, const ExecutableItem &second)
 Returns a Group with first and second tasks merged with conjunction.
TASKING_EXPORT friend Group operator|| (const ExecutableItem &first, const ExecutableItem &second)
 Returns a Group with first and second tasks merged with disjunction.
TASKING_EXPORT friend Group operator&& (const ExecutableItem &item, DoneResult result)
TASKING_EXPORT friend Group operator|| (const ExecutableItem &item, DoneResult result)

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)>
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

Base class for executable task items. \reentrant

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.

Definition at line 316 of file tasktree.h.

Constructor & Destructor Documentation

◆ ExecutableItem() [1/2]

Tasking::ExecutableItem::ExecutableItem ( )
protecteddefault

◆ ExecutableItem() [2/2]

Tasking::ExecutableItem::ExecutableItem ( const TaskHandler & handler)
inlineprotected

Definition at line 329 of file tasktree.h.

References Tasking::GroupItem::GroupItem().

Here is the call graph for this function:

Member Function Documentation

◆ withAccept()

template<typename SenderSignalPairGetter>
Group Tasking::ExecutableItem::withAccept ( SenderSignalPairGetter && getter) const

Definition at line 429 of file tasktree.h.

◆ withCancel()

template<typename SenderSignalPairGetter>
Group Tasking::ExecutableItem::withCancel ( SenderSignalPairGetter && getter,
std::initializer_list< GroupItem > postCancelRecipe = {} ) const

Definition at line 416 of file tasktree.h.

◆ withLog()

Group Tasking::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.

Definition at line 1596 of file tasktree.cpp.

References Tasking::activeTaskTree(), Tasking::TaskTree::asyncCount(), and Tasking::StorageBase::Storage.

Here is the call graph for this function:

◆ withTimeout()

Group Tasking::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.

Definition at line 1562 of file tasktree.cpp.

References Tasking::finishAllAndError, Tasking::parallel, Tasking::stopOnSuccessOrError, and Tasking::Success.

◆ operator!

TASKING_EXPORT friend Group operator! ( const ExecutableItem & item)
friend

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:

onGroupDone([](DoneWith doneWith) { return toDoneResult(doneWith == DoneWith::Error); })
}
DoneResult toDoneResult(bool success)
static GroupItem onGroupDone(Handler &&handler, CallDoneIf callDoneIf=CallDoneIf::SuccessOrError)
Constructs a group's element holding the group done handler.
Definition tasktree.h:447
QGraphicsItem * item
See also
operator&&(), operator||()

Definition at line 1644 of file tasktree.cpp.

References Tasking::Error, and Tasking::toDoneResult().

◆ operator&& [1/2]

TASKING_EXPORT friend Group operator&& ( const ExecutableItem & first,
const ExecutableItem & second )
friend

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 \l {https://en.wikipedia.org/wiki/Short-circuit_evaluation}{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 }
const GroupItem stopOnError
GLint first
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||(), operator!()

Definition at line 1678 of file tasktree.cpp.

References Tasking::stopOnError.

◆ operator&& [2/2]

TASKING_EXPORT friend Group operator&& ( const ExecutableItem & item,
DoneResult result )
friend

Definition at line 1724 of file tasktree.cpp.

References Tasking::finishAllAndError, Tasking::stopOnError, and Tasking::Success.

◆ operator|| [1/2]

TASKING_EXPORT friend Group operator|| ( const ExecutableItem & first,
const ExecutableItem & second )
friend

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 \l {https://en.wikipedia.org/wiki/Short-circuit_evaluation}{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:

const GroupItem stopOnSuccess
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&&(), operator!()

Definition at line 1709 of file tasktree.cpp.

References Tasking::stopOnSuccess.

◆ operator|| [2/2]

TASKING_EXPORT friend Group operator|| ( const ExecutableItem & item,
DoneResult result )
friend

Definition at line 1739 of file tasktree.cpp.

References Tasking::Error, Tasking::finishAllAndSuccess, and Tasking::stopOnError.


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