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

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.