ExecutableItem Class | Extending Qt Creator Manual
Description: Base class for executable task items.

- Extending Qt Creator Manual
- TaskingSolution
- ExecutableItem
- Extending Qt Creator Manual 13.0.1

# ExecutableItem Class

class Tasking::ExecutableItem

Base class for executable task items. More...

Header: | #include <solutions/tasking/tasktree.h>
Inherits: | Tasking::GroupItem
Inherited By: | Tasking::CustomTask, Tasking::Group, and Tasking::Sync

- List of all members, including inherited members

Note: All functions in this class are reentrant.

## Public Functions

Tasking::ExecutableItem | withLog(const QString &logName) const
Tasking::ExecutableItem | withTimeout(std::chrono::milliseconds timeout, const std::function<void ()> &handler = {}) const

## 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::ExecutableItem 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::ExecutableItem 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.