Sync Class

class Tasking::Sync

Synchronously executes a custom handler between other tasks. More...

Header: #include <solutions/tasking/tasktree.h>
Inherits: Tasking::ExecutableItem

Note: All functions in this class are reentrant.

Public Functions

Sync(Handler &&handler)

Detailed Description

Sync is useful when you want to execute an additional handler between other tasks. Sync is seen by its parent Group as any other task. Avoid long-running execution of the Sync's handler body, since it is executed synchronously from the caller thread. If that is unavoidable, consider using ConcurrentCallTask instead.

Member Function Documentation

template <typename Handler> Sync::Sync(Handler &&handler)

Constructs an element that executes a passed handler synchronously. The Handler is of the std::function<DoneResult()> type. The DoneResult value, returned by the handler, is considered during parent group's workflow policy resolution. Optionally, the shortened form of std::function<void()> is also accepted. In this case, it's assumed that the return value is DoneResult::Success.

The passed handler executes synchronously from the caller thread, so avoid a long-running execution of the handler body. Otherwise, consider using ConcurrentCallTask.

Note: The Sync element is not counted as a task when reporting task tree progress, and is not included in TaskTree::taskCount() or TaskTree::progressMaximum().